Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Tom Lane
Douglas Alan writes: > Hey, while I have you on the line, might you be so kind as to explain why > this query is so slow? Shouldn't it just fetch the first row in the table? > > explain analyze select * from maindb_astobject limit 1; Yeah ... >> QUERY >> PLAN >> >>

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Alvaro Herrera
Douglas Alan escribió: > Hey, while I have you on the line, might you be so kind as to explain why > this query is so slow? Shouldn't it just fetch the first row in the table? > What could be faster than that? > > explain analyze select * from maindb_astobject limit 1; > > > >

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Douglas Alan
On Tue, Jun 2, 2009 at 9:52 AM, Tom Lane wrote: > > delete from pg_statistic > where (starelid, staattnum) in > (select attrelid, attnum from pg_attribute > where attrelid = 'my_relation'::regclass and attname = 'my_attribute'); > > regclass knows about schemas and search paths, so stuff like

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Tom Lane
Douglas Alan writes: > delete from pg_statistic s > where exists ( select 1 > from pg_class as c, pg_attribute as a > where a.attrelid = c.relfilenode > and s.starelid = c.relfilenode > and s.staattnum = a.attnum > and c.relname = 'maindb_astobject' > and attname = 'survey_id' > ); Use c.oid, not

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Isak Hansen
On Mon, Jun 1, 2009 at 8:20 PM, Douglas Alan wrote: > I'd like to manually alter the statistics for a column, as for the column in > question the statistics are causing Postgres to do the wrong thing for my > purposes. (I.e., a Seq Scan, rather than an Index Scan.)  If someone can > tell me how to

Re: [GENERAL] How can I manually alter the statistics for a column?

2009-06-02 Thread Douglas Alan
If you want something done right, I guess you have to do it yourself! Here's the answer to my question. It works great! Or so it seems to: delete from pg_statistic s where exists ( select 1 from pg_class as c, pg_attribute as a where a.attrelid = c.relfilenode and s.starelid = c.relfilenode and

[GENERAL] How can I manually alter the statistics for a column?

2009-06-01 Thread Douglas Alan
I'd like to manually alter the statistics for a column, as for the column in question the statistics are causing Postgres to do the wrong thing for my purposes. (I.e., a Seq Scan, rather than an Index Scan.) If someone can tell me how to achieve this, I would quite grateful. Thanks! |>ouglas P.