Re: best use of index and missing values

2006-04-19 Thread Philippe Poelvoorde
2006/4/14, Philippe Poelvoorde <[EMAIL PROTECTED]>:
> Hi,
>
> I have one table :
> CREATE TABLE `ressources_summary` (
>   `res_type` tinyint(3) unsigned NOT NULL default '0',
>   `res_id` int(10) unsigned NOT NULL default '0',
>   `comment_count` smallint(5) unsigned NOT NULL default '0',
>   `comment_last_timestamp` timestamp NOT NULL default '-00-00 00:00:00',
>   `comment_last_user_id` int(11) NOT NULL default '0',
>   PRIMARY KEY  (`res_type`,`res_id`)
> ) ENGINE=MyISAM
>
> it gather summary on comments for any ressources (poll, articles,
> forums, admin). A ressource is uniquely identify by (res_type,
> res_id), the others columns are self-explanatory (I hope).
> I'm wondering about the efficiency of storing a comment_count of 0
> (and user_id=0, timestamp=0).
> There is comments on 20% of the ressources.
> What is the cost of looking for a row that does not exists in a table ?
> Would it be more efficient to only store summary for comment_count
> greater than 0 and knowing missing rows have a count of zero, or to
> store everything ?

I went for the version without all zeros. It dramatically reduce the
number of rows,  and overall performances are better with this summary
table.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



best use of index and missing values

2006-04-14 Thread Philippe Poelvoorde
Hi,

I have one table :
CREATE TABLE `ressources_summary` (
  `res_type` tinyint(3) unsigned NOT NULL default '0',
  `res_id` int(10) unsigned NOT NULL default '0',
  `comment_count` smallint(5) unsigned NOT NULL default '0',
  `comment_last_timestamp` timestamp NOT NULL default '-00-00 00:00:00',
  `comment_last_user_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`res_type`,`res_id`)
) ENGINE=MyISAM

it gather summary on comments for any ressources (poll, articles,
forums, admin). A ressource is uniquely identify by (res_type,
res_id), the others columns are self-explanatory (I hope).
I'm wondering about the efficiency of storing a comment_count of 0
(and user_id=0, timestamp=0).
There is comments on 20% of the ressources.
What is the cost of looking for a row that does not exists in a table ?
Would it be more efficient to only store summary for comment_count
greater than 0 and knowing missing rows have a count of zero, or to
store everything ?

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]