in reply to sloooowwwwww code!
Good advice on profiling aside, I would start with the query and database schema. A lot of time can get chewed up by an inefficient query, or one that could be sped up by adding indexes.
Look at the query
and ask two questions:select text_id,gene_name,protein5,protein3 from protein where org_id=$orgid order by protein5 desc"
I can't tell from your code whether it matters whether the query results are sorted or not. If it doesn't matter, drop the order by clause.
The non-SQL thing that jumped out was the redundant trig calculations. You're doing each sine and cosine calculation twice, where once would be sufficient.
Then profile.
|
|---|