rails/rails — pull request #3812 by pimeys (2011-11-30 17:04:10+00:00)
Title: Performance issues using tables with no primary key

Operations like create for a model which table has no primary keys has horrible performance. ActiveRecord is doing queries like `SHOW INDEX FROM 'table_name' WHERE Key_name = 'PRIMARY'` 20-30 times per action. It will really affect performance with lots of requests per minute.

Now here's a quick fix to the problem, that sets the @primary_key variable only once, even when the database returns no primary keys.