Re: Database tuning

From: Nevermind <never(at)nevermind(dot)kiev(dot)ua>
To: Antonio Fiol Bonnin <fiol(at)w3ping(dot)com>
Cc: K Old <kevsurf4(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Database tuning
Date: 2001-12-21 19:53:19
Message-ID: 20011221215319.C39983@nevermind.kiev.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello, Antonio Fiol Bonnin!

On Fri, Dec 21, 2001 at 06:41:41PM +0100, you wrote:

> XXX is a random value ranking from 0 (or 1) to the maximum id value. You
> generate it outside the database.
Maximum id is not good solution, beacuse some of ids between 0 (or 1)
could be missing for some reasons. You should:

select id from table;

Then chose random one outside SQL, and then:

select * from table where table.id = '$random_id';

This would be slower but will work for sure.

Another approach -- select random id outside SQL from 0 (or 1) to
maximum_id and then trying to select with 'where table.id =
'$random_id'' until you've got > 0 rows in result.

--
NEVE-RIPE

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Helge Bahmann 2001-12-21 20:09:24 udp port
Previous Message Tom Lane 2001-12-21 19:31:11 Re: Is the Windows Version Stable?