RE: Bad estimates

2017-11-22 Thread Artur Zając
ovember 22, 2017 4:02 PM To: Artur Zając Cc: pgsql-performance@lists.postgresql.org Subject: Re: Bad estimates =?iso-8859-2?Q?Artur_Zaj=B1c?= writes: [ poor estimates for WHERE clauses like "(gs & 1) = 1" ] Don't hold your breath waiting for that to get better on its own. You

Re: Bad estimates

2017-11-22 Thread Laurenz Albe
Artur Zając wrote: > We have table created like this: > > CREATE TABLE xyz AS SELECT generate_series(1,1000,1) AS gs; > > Now: > > explain analyze select * from xyz where gs&1=1; > Seq Scan on xyz (cost=0.00..260815.38 rows=68920 width=4) > (actual time=0.044..2959.728 r

RE: Bad estimates

2017-11-22 Thread Alex Ignatov
rmance@lists.postgresql.org Subject: Re: Bad estimates I'm assuming you never analyzed the table after creation & data load? What does this show you: select * from pg_stat_all_tables where relname='xyz'; Don. -- Don Seiler www.seiler.us <http://www.seiler.us>

Re: Bad estimates

2017-11-22 Thread Tom Lane
=?iso-8859-2?Q?Artur_Zaj=B1c?= writes: [ poor estimates for WHERE clauses like "(gs & 1) = 1" ] Don't hold your breath waiting for that to get better on its own. You need to work with the planner, not expect it to perform magic. It has no stats that would help it discover what the behavior of tha

Re: Bad estimates (DEFAULT_UNK_SEL)

2017-11-22 Thread Justin Pryzby
On Wed, Nov 22, 2017 at 03:29:54PM +0100, Artur Zając wrote: > CREATE TABLE xyz AS SELECT generate_series(1,1000,1) AS gs; > > db=# explain analyze select * from xyz where gs&1=1; > Seq Scan on xyz (cost=0.00..260815.38 rows=68920 width=4) (actual > time=0.044..2959.728 rows=500 loops=1

Re: Bad estimates

2017-11-22 Thread Don Seiler
I'm assuming you never analyzed the table after creation & data load? What does this show you: select * from pg_stat_all_tables where relname='xyz'; Don. -- Don Seiler www.seiler.us

Bad estimates

2017-11-22 Thread Artur Zając
Hi, We have table created like this: CREATE TABLE xyz AS SELECT generate_series(1,1000,1) AS gs; Now: db=# explain analyze select * from xyz where gs&1=1; QUERY PLAN --