Re: Create one query out of two
От
Kevin Grittner
Тема
Re: Create one query out of two
Дата
Msg-id
1376857421.73679.YahooMailNeo@web162906.mail.bf1.yahoo.com
Ответ на
Create one query out of two (Robert DiFalco)
Список
Дерево обсуждения
Create one query out of two Robert DiFalco <robert.difalco@gmail.com>
Re: Create one query out of two Kevin Grittner <kgrittn@ymail.com>
Re: Create one query out of two Calvin Dodge <caldodge@gmail.com>
Robert DiFalco wrote:> > UPDATE contacts SET user_id = u.id > FROM my_users u > JOIN phone_numbers pn ON u.phone_significant = pn.significant > WHERE contacts.owner_id = 7 AND contacts.user_id IS NULL > AND contacts.id = pn.ref_contact_id; > > UPDATE contacts SET user_id = u.id > FROM my_users u > JOIN email_addresses em ON u.email = em.email > WHERE contacts.owner_id = 7 AND contacts.user_id IS NULL > AND contacts.id = em.ref_contact_id; > > They are running slower than I'd like them to even though I have > indices on user_id, owner_id, email, and significant. Have you tried those queries with an index like this?: CREATE INDEX contacts_owner_null_user ON contacts (owner_id) WHERE user_id IS NULL; -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
В списке pgsql-performance по дате отправления