Re: some points for FAQ - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: some points for FAQ
Date
Msg-id 162867790710091351g3479868fyb8f7259352063c17@mail.gmail.com
Whole thread Raw
In response to Re: some points for FAQ  (Bruce Momjian <bruce@momjian.us>)
Responses Re: some points for FAQ
List pgsql-hackers
2007/10/9, Bruce Momjian <bruce@momjian.us>:
> Pavel Stehule wrote:
> > 4.1)
> >
> >  To SELECT a random row, use:
> >     SELECT col
> >     FROM tab
> >     ORDER BY random()
> >     LIMIT 1;
> >
> > + On bigger tables this solution is slow. Please, find smarter
> > solution on network.
> >
>
> Well, give me a better example that works.

Better universal solution doesn't exist. Exists only unelegant
solutions - but mutch faster.

SELECT id, ...  FROM data WHERE id = ANY(ARRAY(                      SELECT (random()*:max_id)::int
   FROM generate_series(1,20))) LIMIT 1;
 

max_id is host variable ~ real max id + some

-- fast solution if id is PK of data

>
> > 4.19)
> >
> > + most of problems with invalid OIDs in cache are solved in PostgreSQL
> > 8.3. Please remeber, so every replanning of SQL statements needs time.
> > Write your application, they can exist without cache invalidation.
>
> Agreed.  Item removed.
>

Cache invalidation isn't 100% protection before this error message.
With specific using of EXECUTE statement, you can get this message
too. But all temp tables related problems are solved.


Regards
Pavel Stehule


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Skytools committed without hackers discussion/review
Next
From: Bruce Momjian
Date:
Subject: Re: some points for FAQ