how to select several random records from DB

User 247c00dc1d

14-08-2012 15:27:47

Hello!


Is it possible to display random 600000 records in the database consisting of 1.5 million records.


maybe you can write a script that will display the specified number of records from the database...


thanks!

ChemAxon 60ee1f1328

15-08-2012 08:51:12

Hi Igorlab,


If you use MYSQL which I think you do then a possible simpler alternative to a script is to use SQL filter option of an entity. http://www.chemaxon.com/instantjchem/ijc_latest/docs/user/help/htmlfiles/security/row_level_security.html


You could try out the SQL snippet below with X is hardcoded :



ORDER BY RAND () LIMIT X


Thanks,


Daniel

User 247c00dc1d

15-08-2012 12:35:13










DanielSButler wrote:

 http://www.chemaxon.com/instantjchem/ijc_latest/docs/user/help/htmlfiles/security/row_level_security.html



Hi, I've added the script from example (as in image), then "applay", and "show All" but query retyrned no hits...

ChemAxon fa971619eb

15-08-2012 12:44:32

This script might be of interest: http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/scripts/create_diverse_subset.html


It does a lot more than you are wanting - it creates a randomly selected diverse set of compounds. But it shows how a random set of row IDs coudl be created. Its probably very easy simplfy it to do just that.


Tim


 

User 247c00dc1d

15-08-2012 14:04:35










tdudgeon wrote:

This script might be of interest: http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/scripts/create_diverse_subset.html


It does a lot more than you are wanting - it creates a randomly selected diverse set of compounds. But it shows how a random set of row IDs coudl be created. Its probably very easy simplfy it to do just that.


Tim


 



Thank you very much! it's very helpful!and one more question: when  I trying to load list with more than 100000 hits its running a very long time but not gave result even after 4 h, is it normal and I have to waiting for more time? or it's error...


thanks,


Igor

ChemAxon 2bdd02d1e5

15-08-2012 16:02:04

Using list of appx. 100000 rows is currently not possible. List are designated to be used with appx. 10000 rows at maximum to finish in reasonable time. We plan to improve of handling lists in some future version.


Thanks for your understanding.


Filip