Author Topic: Large table and query time  (Read 1086 times)

0 Members and 1 Guest are viewing this topic.

Offline jaymcTopic starter

  • Addict
  • Gender: Male
    • View Profile
Re: Large table and query time
« Reply #15 on: August 14, 2008, 06:38:12 AM »
Your DB design here is full of fail.

Do you handle tons of inserts/updates to this table? If not, switch the engine to isam.

What would you consider as tons of updates/inserts. How many a second to justify it being innodb?
I would love to change the world, but they won't give me the source code

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Insane!'
  • *
  • Gender: Male
    • View Profile
Re: Large table and query time
« Reply #16 on: August 14, 2008, 10:09:55 AM »
I will echo the previous comment about COUNT(*) and InnoDB -- have a summary table.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

Offline Xurion

  • Enthusiast
    • View Profile
Re: Large table and query time
« Reply #17 on: August 14, 2008, 04:16:57 PM »
Change your tables to myisam. Count works faster on these.

Offline corbin

  • Guru
  • Freak!
  • *
  • Gender: Male
    • View Profile
Re: Large table and query time
« Reply #18 on: August 14, 2008, 05:26:46 PM »
Change your tables to myisam. Count works faster on these.



But MyISAM does table locks, instead of row locks.  If he has lots of updates/deletes, MyISAM could be a bad idea.
Why doesn't anyone ever say hi, hey, or whad up world?

Offline awpti

  • Enthusiast
  • Gender: Male
    • View Profile
    • GeekLAN Networks Blog
Re: Large table and query time
« Reply #19 on: August 14, 2008, 10:14:53 PM »
His next best option is to switch to MySQL 5.1 and start making use of partitions.

That's HUGE.

I tried his table layout on my own server with partitions and ~20M rows.

Queries that took 2-3 minutes without partitions took ~5-10 seconds tops with.

Lots of solutions to this issue. count() on an innodb table is just bad news.

A summary table wouldn't be a bad idea at all.. just make a single field table with a value you add/subtract from based upon the addition or subtraction of rows.
Server: Apache 2.2.11 - PHP 5.2.9, 6.0.0-dev - MySQL 5.0, 5.1 and 6.0 - Core2Duo 2.66Ghz, 4GB Mem
GeekLAN - Ignited Jobs - LAMP Tips

10+ Years of hobby PHP Development and Database Design.

Offline jaymcTopic starter

  • Addict
  • Gender: Male
    • View Profile
Re: Large table and query time
« Reply #20 on: August 17, 2008, 02:44:57 PM »
This martition stuff in 5.1

Does MYSQL fully take care of it as in manage the data, or is it something I need to take care of on query level

Sounds nice
I would love to change the world, but they won't give me the source code

Offline Mchl

  • Freak!
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • BOINC@Poland
Re: Large table and query time
« Reply #21 on: August 17, 2008, 02:51:06 PM »
I'd really like to try it out as well.
It seems that apart from defining partitions, the rest is taken care of by mysql.

awpti: Into how many parts did you partition your 20Mrows table?
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Code: [Select]
import java;

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.