Re: DB Query
| From: | Marek Kilimajer | Date: | Sat, 05 Jun 2004 16:55:49 +0000 |
| Subject: | Re: DB Query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187694@lists.php.net to get a copy of this message | ||
bskolb wrote:
I'm trying to optimize a query that in the first example is taking too long to run. This is my existing working query: $sql = "SELECT count(*) as cnt, id FROMEven if the syntax whould be possible, it whould not help any. SQL server optimize queries before executing them, and your second query would be the same as the first one. What is the column type of c1,c2,c3,c4 and c5? What indexes did you create?mYTableWHERE c1 not in (1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not in (1,16,36) and c5 not in (1,16,36) GROUP BY id"; Is it possible to do something like this instead (This doesn't work of course) $sql = "SELECT count(*) as cnt, id FROMmyTableWHERE (c1,c2,c3,c4,c5) not in (1,16,36) GROUP BY id"; Any other suggestions are appreciated, Thanks!