in reply to Re^2: How to increase the efficiency of the code wen working with DB?
in thread How to increase the efficiency of the code wen working with DB?
That doesn't look too bad but of course you have to do the last one almost 400000 times, so that will take a while.
I haven't looked at your queries too closely but is there a reason why you need to issue a query for genotypes with a single sample and a single snp instead of querying for all samples IN (...) and all snps IN (...) in one go? That should be a lot faster. You can associated sample, genotype and snp in your perl script by parsing the results. Other than that I would still look at the indices, which might not be optimal for your queries, and also at the sorting you let the DB do - that too will take time and might not be necessary, depending on how you use the data afterwards.