timestamp with time zone

Поиск
Список
Период
Сортировка
От Alessandro Gagliardi
Тема timestamp with time zone
Дата
Msg-id CAAB3BBJnD+dcaOQ_T8g+y==zen9yuOj2NvXrE5vhVe=RP28hMw@mail.gmail.com
обсуждение исходный текст
Ответы Re: timestamp with time zone  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Here's my query:

SELECT foursquare.name, foursquare.city, COUNT(moment_id) AS popularity
FROM foursq_categories 
JOIN foursquare USING (foursq_id)
JOIN places USING (foursq_id)
JOIN blocks USING (block_id)
WHERE "primary" 
  AND (created at time zone timezone)::date = 'yesterday'
  AND (country = 'USA' OR country = 'United States')
  AND foursq_categories.name @@ to_tsquery('Restaurant') 
GROUP BY foursq_id, foursquare.name, foursquare.city ORDER BY popularity DESC LIMIT 12;


To my surprise, it was not the tsquery that made this slow (which is awesome, because I was worried about that) but rather the filter: (created at time zone timezone)::date = 'yesterday'
created has an index (btree if it matters). timezone does not. I'm wondering if the solution to my problem is to create a joint index between created and timezone (and if so, if there is a particular way to do that to make it work the way I want).

Thanks in advance.

-Alessandro

В списке pgsql-performance по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: random_page_cost = 2.0 on Heroku Postgres
Следующее
От: Tom Lane
Дата:
Сообщение: Re: timestamp with time zone