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.
Optimizing a query
Moderator: General Moderators
-
x_mutatis_mutandis_x
- Forum Contributor
- Posts: 160
- Joined: Tue Apr 17, 2012 12:57 pm
Re: Optimizing a query
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
shiznatix must have meant count(distinct companies.companyid) (which is, of course, different from distinct count(companyid))
-
x_mutatis_mutandis_x
- Forum Contributor
- Posts: 160
- Joined: Tue Apr 17, 2012 12:57 pm
Re: Optimizing a query
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 slowWeirdan wrote:shiznatix must have meant count(distinct companies.companyid) (which is, of course, different from distinct count(companyid))
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Re: Optimizing a query
Edit: ignore me.