Re: Select Single Random Record

Hans Georg Schaathun <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
On Wed, Apr 18, 2012 at 09:43:23PM +0200, Petr Jakeš wrote:
> > Although this might work in the particular application, but
> > it is hardly ideal to make two queries, nor to load a long list
> > of IDs.  Is there a way to do it with a single query?
> >
> > 1)
> Is your task really "time critical"?

In my case, yes; it is number crunching.
Question should be «is it /that/ "time critical"» :-)
I have had some difficulties with slow operations due
to multiple queries, and it feels more satisfactory get
rid of any avoidable query, even if the saving is only
a fraction of a percent of the total running time.

> How many records (IDs) do you expect to be returned using the first select?

thousands in current tests;
hundreds of thousands is likely in future tests,
and millions is plausible.

> How many kb will it take? Is the list size a real problem for your Internet
> connection?

Might be; especially when it is over the Internet as opposed to
over a LAN.  Yet, I am as concerned with query processing time than
transmission time.

> How often do you expect to release the select querry?

Could vary.  About 50 clients querying once a minute each
may be typical, but I am sure I will see faster jobs completing
in seconds, in which case each client would query correspondingly
often.

> 2)
> what is your target database engine?

postgres at the moment.

> some databases allow "rand" in the select query.
> see:
> http://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql

Ah.  Thanks for the tip.
I will look into it; obviously, I would prefer the solution to
be engine independent, but this feature might be more valuable :-)

:-- George
> 
> Petr

-- 
:-- Hans Georg

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.