agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedPGSQL-Performance mailing list.
2+ messages / 2 participants
[nested] [flat]
* PGSQL-Performance mailing list.
@ 2002-09-27 19:05 Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2002-09-27 19:05 UTC (permalink / raw)
To: pgsql-sql; pgsql-php@postgresql.org; pgsql-novice@postgresql.org
Hey, folks!
I'm mailing to remind everyone about the new PGSQL-PERFORMANCE mailing list.
This list was added about 2 weeks ago to provide a forum for the following
topics:
1. Postgres server hardware tuning.
2. Postgresql.conf tweaking
3. Index management
4. VACUUMing, ANALYZE and STATISTICS
5. query parsing for efficiency
6. etc.
Please join me there! To subscribe, send an e-mail to:
pgsql-performance-request@postgresql.org
... with only the word "subscribe" in the body of the message.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 2+ messages in thread
* PGSQL-Performance mailing list
@ 2015-07-02 10:52 John Sherwood <john@gleam.io>
0 siblings, 0 replies; 2+ messages in thread
From: John Sherwood @ 2015-07-02 10:52 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm having some trouble getting this query down for large users.
Basically, we deal with competition entries. For this customer (a.k.a.
site) we've got ~1,000,000 entries from ~100,000 contestants.
SELECT contestants.*, sum(entries.worth) as db_entries, count(entries.id)
as db_actions FROM "contestants" INNER JOIN "entries" ON
"entries"."contestant_id" = "contestants"."id" WHERE
"entries"."campaign_id" IN (SELECT id FROM "campaigns" WHERE
"campaigns"."site_id" = $1) AND (entries.status != 'Invalid') GROUP BY
contestants.id ORDER BY db_actions desc LIMIT 20 OFFSET 0
Here's the explain:
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=3783168.28..3783168.33 rows=20 width=103)
-> Sort (cost=3783168.28..3792902.85 rows=3893825 width=103)
Sort Key: (count(entries.id))
-> GroupAggregate (cost=3004896.86..3679555.00 rows=3893825
width=103)
-> Merge Join (cost=3004896.86..3611413.06 rows=3893825
width=103)
Merge Cond: (contestants.id = entries.contestant_id)
-> Index Scan using contestants_pkey on contestants
(cost=0.43..534782.85 rows=7490021 width=95)
-> Sort (cost=3004710.57..3014464.64 rows=3901628
width=12)
Sort Key: entries.contestant_id
-> Nested Loop (cost=19.88..2577567.27
rows=3901628 width=12)
-> Bitmap Heap Scan on campaigns
(cost=19.32..1332.62 rows=374 width=4)
Recheck Cond: (site_id = 152)
-> Bitmap Index Scan on
index_campaigns_on_site_id (cost=0.00..19.22 rows=374 width=0)
Index Cond: (site_id = 152)
-> Index Scan using
index_entries_on_campaign_id on entries (cost=0.57..6784.01 rows=10432
width=16)
Index Cond: (campaign_id =
campaigns.id)
Filter: ((status)::text <>
'Invalid'::text)
Any thoughts on tweaks I could apply to speed this up?
Thanks,
John
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2015-07-02 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-27 19:05 PGSQL-Performance mailing list. Josh Berkus <josh@agliodbs.com>
2015-07-02 10:52 PGSQL-Performance mailing list John Sherwood <john@gleam.io>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox