English 中文(简体)
表格中的铁路移民指数
原标题:Rails migration index for joined tables

使用铁路3的Im和我的生产 d在Heroku。 我如何为这一问题制定适当的指数? 我不知道如何为内部人创造一种机会,使他们加入到这一时刻。

SELECT "plans".* FROM "plans" 
INNER JOIN "schedules" 
ON "plans".schedule_id = "schedules".id 
WHERE (("schedules".user_id = 4))
最佳回答

你们应当能够增加一个附表索引。

add_index :schedules, :user_id

......和另一个按计划分列的指数:

add_index :plans, :schedule_id

此外,如果你重新努力装上所有附表或相关计划,你可能会使用左边:

select plans.*
  from schedules
  left join plans on plans.schedule_id = schedule.id
  where schedules.user_id = 4

我认为,左边合在一起对你们在这里想要的东西是正确的。

问题回答

暂无回答




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签