From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Emmanuel Cecchet <Emmanuel(dot)Cecchet(at)asterdata(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "manu(at)frogthinker(dot)org" <manu(at)frogthinker(dot)org> |
Subject: | Re: Wrong stats for empty tables |
Date: | 2009-05-05 19:30:18 |
Message-ID: | 603c8f070905051230w55c4c6cbwcb8eea7d5201f5f4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, May 5, 2009 at 2:03 PM, Emmanuel Cecchet
<Emmanuel(dot)Cecchet(at)asterdata(dot)com> wrote:
> So what is the rationale behind not being able to use indexes and optimizing empty tables as in the following example:
>
> manu=# create table father (id int, val int, tex varchar(100), primary key(id));
> manu=# create table other (id1 int, id2 int, data varchar(10), primary key(id1,id2));
> insert some data
> manu=# explain select father.*,id2 from father left join other on father.id=other.id1 where id2=2 order by id;
Just because the table was empty at the time statistics were most
recently gathered doesn't mean it's still empty at the time the query
is executed.
ANALYZE;
PREPARE foo AS SELECT ...;
INSERT INTO ...some previously empty child table...
EXECUTE foo;
In order to rely on this for query planning, you'd need some way to
invalidate any cached plans when inserting into an empty table.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2009-05-05 19:39:32 | Re: bytea vs. pg_dump |
Previous Message | mito | 2009-05-05 19:13:15 | Re: Values of fields in Rules |