SQL query with COUNT(DISTINCT

abautu - February 17, 2007 - 19:34
Project:Drupal
Version:5.1
Component:watchdog.module
Category:feature request
Priority:normal
Assigned:abautu
Status:duplicate
Description

Hello,

I'm working on a SQLite layer for Drupal as a hobby. It's very functional, but I have the following problem: your module uses some queries with COUNT(DISTINCT(...)). I'm not sure is this syntax is SQL standard, but it can by rewritten using a GROUP BY clause (in a 100% standard way). For instance:
in line 170: "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'" could be replaced with "SELECT COUNT(*) FROM {watchdog} WHERE type = '%s'" GROUP BY message';

You may notice that the queries I'm suggesting are shorter, cleaner (you may cleary see that you are counting all the lines) and maybe faster (because of possible GROUP BY optimizations).

Best wishes,
Andrei.

#1

abautu - February 17, 2007 - 22:09
Assigned to:Anonymous» abautu
Status:active» patch (reviewed & tested by the community)

I learned how to use a CVS, how Drupal CVS works, how patches are made and I thought to give it a try. I've tested the patch on my installation.

AttachmentSize
watchdog_7.patch1004 bytes

#2

Crell - February 17, 2007 - 23:11
Status:patch (reviewed & tested by the community)» duplicate

1) Do not post duplicate issues to different issue queues.
2) Do not set your own patch to "ready to be committed".
3) New features go against 6.x, not against the stable version.
4) Do check the issue queue before posting, as there is already an effort for SQLite support: http://drupal.org/node/67349

Thank you.

 
 

Drupal is a registered trademark of Dries Buytaert.