Say, I have a pictures table, and there are many objects which can have
pictures, so I define a picturable type. Now, to make the query for
more efficient I should index the picture table using both
Is this the correct approach to indexing the table, or can things be
better? I want the database retrieval operation to be extremely fast (I
some other types such as votes, which require many queries and the speed
query retrieval is important).
Thanks in advance for your help and suggestions.
create_table :pictures do |table| table.column :name, :string, :limit => 100 table.column :content_type, :string, :limit => 100 table.column :data, :blob table.column :picturable_id, :int, :null => false table.column :picturable_type, :string, :limit => 10, :null =>
add_index :pictures, [:picturable_type], :name =>
add_index :pictures, [:picturable_id], :name =>
Read my blog at: http://cuttingtheredtape.blogspot.com/
| “War is Peace! Freedom is Slavery! Ignorance is Strength!”
| – Orwell, 1984, 1948