Re: [HACKERS] optimization join on random value

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Anton <djeday84(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: [HACKERS] optimization join on random value
Date: 2015-05-04 02:10:02
Message-ID: 5546D4FA.6080904@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 5/3/15 4:15 PM, Anton wrote:
> Hello guru of postgres, it's possoble to tune query with join on random
> string ?
> i know that it is not real life example, but i need it for tests.

Moving to -general, which is the proper list for this. (BCC -hackers)

> soe-# WHERE customer_id = trunc( random()*45000) ;

You could create a temp table with the random value and JOIN to it:

CREATE TEMP TABLE rnd AS SELECT random()*45000;

Another option might be to use a prepared statement:

PREPARE test AS SELECT ... WHERE customer_id = $1;
EXECUTE test( random()*45000 );
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2015-05-04 02:16:12 Re: Errors using JDBC batchUpdate with plpgsql function
Previous Message Craig Ringer 2015-05-04 01:39:23 Re: Removing and readding bdr nodes

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Shirokov 2015-05-04 03:20:15 JSON data type and schema validation
Previous Message Jim Nasby 2015-05-04 02:03:15 Re: CTE optimization fence on the todo list?