[PERFORM] working around JSONB's lack of stats?

2015-01-26 Thread Josh Berkus
Folks, Currently, JSONB fields don't have statistics, and estimate a flat 1% selectivity. This can result in poor query plans, and I'm wondering if anyone has a suggested workaround for this short of hacking a new selectivity function. For example, take the common case of using JSONB to hold a l

Re: [PERFORM] Why is PostgreSQL not using my index?

2015-01-26 Thread Tomas Vondra
Hi, On 26.1.2015 17:32, Christian Roche wrote: > select * > > from mixpanel_events_201409 mp > > inner join mixpanel_event_list ev on ( ev.id = mp.event_id ) > > where ev.id in (3, 4, 5, 6, 7, 8, 9, 10, 11, 373, 375, 376, 318); > > > > Hash Join (cost=20.73..2892183.32 rows=487288 width=

Re: [PERFORM] Why is PostgreSQL not using my index?

2015-01-26 Thread Tom Lane
"Christian Roche" writes: > Now when I select a subset of the possible event IDs in the big table, PG > uses the appropriate index: > select * > from mixpanel_events_201409 > where event_id in (3, 4, 5, 6, 7, 8, 9, 10, 11, 373, 375, 376, 318); > Bitmap Heap Scan on mixpanel_events_201409 (c

Re: [PERFORM] How to tell ANALYZE to collect statistics from the whole table?

2015-01-26 Thread Jeff Janes
On Sat, Jan 24, 2015 at 9:14 PM, Tom Lane wrote: > AlexK987 writes: > > The documentation states that "The extent of analysis can be controlled > by > > adjusting the default_statistics_target configuration variable". It looks > > like I can tell Postgres to create more histograms with more bins

[PERFORM] Why is PostgreSQL not using my index?

2015-01-26 Thread Christian Roche
Hi guys, Can I take a jab at the celebrated “why is Postgres not using my index” riddle? I’m using PostgreSQL 9.3.3 on an Amazon RDS “db.r3.xlarge” 64-bit instance. I have two tables, one with about 30M rows and two indexes (in fact a monthly partition): CREATE TABLE staging.mixpanel_events_20