Page 2 of 2
Re: Optimizing a query
Posted: Tue Apr 24, 2012 1:29 am
by shiznatix
Gosh, sorry, I was being really stupid for a minute there. I was using a limit/offset that wouldn't be including the first result and then I was wondering why it wasn't working.
I think I am all patched up over here. Thank you Weirdan and Mikosiko - your help is greatly appreciated.
Re: Optimizing a query
Posted: Tue Apr 24, 2012 2:20 pm
by x_mutatis_mutandis_x
I just noticed as to why there is a "DISTINCT COUNT(companies.companyid )" in your query? Instead just do "SELECT COUNT(companies.companyid ) ", it should always return 1 row
Re: Optimizing a query
Posted: Tue Apr 24, 2012 3:23 pm
by Weirdan
shiznatix must have meant count(distinct companies.companyid) (which is, of course, different from distinct count(companyid))
Re: Optimizing a query
Posted: Tue Apr 24, 2012 4:45 pm
by x_mutatis_mutandis_x
Weirdan wrote:shiznatix must have meant count(distinct companies.companyid) (which is, of course, different from distinct count(companyid))
Ahh then its ok, but from my experience, I tried to avoid using distinct as it usually forces the query to use a temp table and gets really slow
Re: Optimizing a query
Posted: Wed May 09, 2012 7:57 am
by shiznatix
Edit: ignore me.