Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-30 Thread Stefan Keller
Hi Jaime 2011/5/30 Jaime Casanova ja...@2ndquadrant.com wrote: On Sun, May 29, 2011 at 4:55 PM, Stefan Keller sfkel...@gmail.com wrote: 2. There's an autovacuum background process which already does the job, doesn't it? Yes, but in its own time. If you know there has been a batch of

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-30 Thread Alban Hertroys
On 29 May 2011, at 23:55, Stefan Keller wrote: Hi Alban On 2011/5/29 Alban Hertroys wrote: On 29 May 2011, at 19:45, Stefan Keller wrote: But I'm hesitating to use ANALYZE for two reasons: 1. It's very slow: it repeadly takes 59000 ms on my machine. ANALYZE on a single table takes

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-29 Thread Stefan Keller
Hi Craig Thanks for the answer. I also thought about this. You mean something like this? SELECT reltuples FROM pg_class WHERE relname = 'mytable'; 182820 (rows) That seams reasonably fast compared to count(*). But I'm hesitating to use ANALYZE for two reasons: 1. It's very slow: it repeadly

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-29 Thread Alban Hertroys
On 29 May 2011, at 19:45, Stefan Keller wrote: But I'm hesitating to use ANALYZE for two reasons: 1. It's very slow: it repeadly takes 59000 ms on my machine. ANALYZE on a single table takes 59s?!? That's _really_ long. How big is that table (it has about 180k rows, you did provide that

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-29 Thread Stefan Keller
Hi Alban On 2011/5/29 Alban Hertroys wrote: On 29 May 2011, at 19:45, Stefan Keller wrote: But I'm hesitating to use ANALYZE for two reasons: 1. It's very slow: it repeadly takes 59000 ms on my machine. ANALYZE on a single table takes 59s?!? That's _really_ long. How big is that table (it

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-29 Thread Craig Ringer
On 05/30/2011 05:55 AM, Stefan Keller wrote: Hi Alban On 2011/5/29 Alban Hertroys wrote: On 29 May 2011, at 19:45, Stefan Keller wrote: But I'm hesitating to use ANALYZE for two reasons: 1. It's very slow: it repeadly takes 59000 ms on my machine. ANALYZE on a single table takes 59s?!?

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-29 Thread Jaime Casanova
On Sun, May 29, 2011 at 4:55 PM, Stefan Keller sfkel...@gmail.com wrote: 2. There's an autovacuum background process which already does the job, doesn't it? Yes, but in its own time. If you know there has been a batch of inserts/deletes you might as well run analyse immediately on that

[GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-28 Thread Stefan Keller
Hi, I’d like to monitor a table in a read-only Postgres database by writing a PL/pgSQL function. The database gets periodically overwritten by a mirroring loading process. The success criteria is, that the table contains at least some records (actually at least more than 10). The first idea

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-28 Thread Stefan Keller
Hi, That's my solution candidate: CREATE OR REPLACE FUNCTION isnotempty() RETURNS boolean AS ' SELECT (count(*) = 1) FROM (SELECT osm_id FROM planet_osm_point LIMIT 1 OFFSET 10) tmp ' LANGUAGE SQL; Yours, Stefan 2011/5/28 Stefan Keller sfkel...@gmail.com: Hi, I’d like to monitor a

Re: [GENERAL] How to check a table content efficiently? With LIMIT and OFFSET?

2011-05-28 Thread Craig Ringer
On 05/29/2011 05:45 AM, Stefan Keller wrote: Hi, That's my solution candidate: CREATE OR REPLACE FUNCTION isnotempty() RETURNS boolean AS ' SELECT (count(*) = 1) FROM (SELECT osm_id FROM planet_osm_point LIMIT 1 OFFSET 10) tmp ' LANGUAGE SQL; LIMIT and OFFSET are often no more