Re: [PHP-DB] Table optimization ideas needed

2008-03-27 Thread Shelley
On Thu, Mar 27, 2008 at 1:55 PM, Chris <[EMAIL PROTECTED]> wrote: > Good idea. But I wonder whether calling the trigger each insert will loose > > any performance. > > > > It's going to affect things slightly but whether it'll be noticable only > you can answer by testing. > > Another option I som

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
Good idea. But I wonder whether calling the trigger each insert will loose any performance. It's going to affect things slightly but whether it'll be noticable only you can answer by testing. Another option I sometimes see is set up a replicated slave and run your reports off that instead of

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
On Thu, Mar 27, 2008 at 10:40 AM, Chris <[EMAIL PROTECTED]> wrote: > > That's never going to be fast because you're using innodb tables. > > > > Should I change it to MyISAM ones? > > > > It depends. > > Do you need or use transactions? You can't change - myisam doesn't support > them. > I ha

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
That's never going to be fast because you're using innodb tables. Should I change it to MyISAM ones? It depends. Do you need or use transactions? You can't change - myisam doesn't support them. No. That's only part of it. I have a cron job, which get the total visits often. If you

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
On Thu, Mar 27, 2008 at 10:03 AM, Chris <[EMAIL PROTECTED]> wrote: > > mysql> explain select count(*) from message; > > > > ++-+-+---+---++-+--+--+-+ > > | id | select_type | table | type | possible_keys | key|

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Chris
mysql> explain select count(*) from message; ++-+-+---+---++-+--+--+-+ | id | select_type | table | type | possible_keys | key| key_len | ref | rows | Extra | ++-+-+---

Re: [PHP-DB] Table optimization ideas needed

2008-03-26 Thread Shelley
Thank you very much, Chris. :) Fyi, On Wed, Mar 26, 2008 at 1:27 PM, Chris <[EMAIL PROTECTED]> wrote: > Shelley wrote: > > > > > +--+---+--+-+---++ > > | Field| Type | Null | Key | Default > > | Extr

Re: [PHP-DB] Table optimization ideas needed

2008-03-25 Thread Chris
Shelley wrote: +--+---+--+-+---++ | Field| Type | Null | Key | Default | Extra | +--+---+--+-+---++ | id

Re: [PHP-DB] Table optimization ideas needed

2008-03-25 Thread Shelley
+--+---+--+-+---++ | Field| Type | Null | Key | Default | Extra | +--+---+--+-+---++ | id | int(11)

Re: [PHP-DB] Table optimization ideas needed

2008-03-25 Thread Chris
Shelley wrote: Yes, Index can help a lot. But actually there has been five indices. The table takes 1.4G space while the indices take 2.3G. The select sentence is still slow. :( Post your exact query, table definition(s), indexes and see if anyone has some suggestions. If it's a mysql db,

Re: [PHP-DB] Table optimization ideas needed

2008-03-25 Thread Shelley
Yes, Index can help a lot. But actually there has been five indices. The table takes 1.4G space while the indices take 2.3G. The select sentence is still slow. :( On Tue, Mar 25, 2008 at 11:50 AM, Chris <[EMAIL PROTECTED]> wrote: > Shelley wrote: > > Hi all, > > > > I made a post a week ago to a

Re: [PHP-DB] Table optimization ideas needed

2008-03-24 Thread J. Hill
From a quick perusal of the article Chris mentions, I'd generally agree with that view about table optimization -- I'm not an expert on Postgres, but the recommendations generally seem to apply to MySQL as well. My basic view is that, if you are routinely doing a select on millions of rows, y

Re: [PHP-DB] Table optimization ideas needed

2008-03-24 Thread Chris
Shelley wrote: Hi all, I made a post a week ago to ask for the idea of the fastest way to get table records. Fyi, http://phparch.cn/index.php/mysql/35-MySQL-programming/126-fastest-way-to-get-total-records-from-a-table Look at the time even a 'count(1)' took. Then you can imagine how much