Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Big look-up table question...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul Madley  
View profile  
 More options Aug 26 2011, 8:12 am
From: Paul Madley <p...@sputnikinternet.com>
Date: Fri, 26 Aug 2011 13:12:25 +0100
Local: Fri, Aug 26 2011 8:12 am
Subject: Big look-up table question...
Hi,

Not *quite* sure if this list is intended for asking this kind of question, but heh you're all experts :o)

We're going to have a list of something like 3 million codes, each with an ID to the item in question, the date it was used, and a few other things.  Currently all in one (MySQL) table called... "codes"

Now, can anybody see a practical advantage/disadvantage to actually having 10 (for example) tables, with an equalisish number of records.  As in, a table for codes starting A&B, C&D, etc etc.

Basically; I wonder if the overhead of PHP deciding which table to query is greater than looking up the records in just one large table.  Any thoughts?

Cheers.

P.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Beckwith  
View profile  
 More options Aug 26 2011, 8:19 am
From: Paul Beckwith <beckwit...@googlemail.com>
Date: Fri, 26 Aug 2011 13:19:07 +0100
Local: Fri, Aug 26 2011 8:19 am
Subject: RE: [phpnw] Big look-up table question...

Hi Paul,

If you split the records up into different tables this will help you when
running queries on the tables as they will be smaller.

As for disadvantages I think it really depends on what you're going to be
doing with the data...

Hope this helps,

Paul Beckwith

Director | iBek Systems Ltd

www.ibeksystems.co.uk

Office:  +44 (0)1253 283924 | Mobile: +44 (0)7708555807

Facebook:  <http://tinyurl.com/4xl6nmy> iBek Systems Ltd  | Twitter:
@ibecsystems


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Waring  
View profile  
 More options Aug 26 2011, 8:30 am
From: Paul Waring <p...@phpdeveloper.org.uk>
Date: Fri, 26 Aug 2011 13:30:49 +0100
Local: Fri, Aug 26 2011 8:30 am
Subject: Re: [phpnw] Big look-up table question...
On 26/08/11 13:12, Paul Madley wrote:

> Not *quite* sure if this list is intended for asking this kind of question, but heh you're all experts :o)

> We're going to have a list of something like 3 million codes, each with an ID to the item in question, the date it was used, and a few other things.  Currently all in one (MySQL) table called... "codes"

> Now, can anybody see a practical advantage/disadvantage to actually having 10 (for example) tables, with an equalisish number of records.  As in, a table for codes starting A&B, C&D, etc etc.

3m rows is not that many in modern databases, MySQL should be able to
find and return records reasonably quickly if you're not running it on
an overloaded server. If your queries are already too slow, experiment
with adding indexes to the columns you search on (i.e. whatever you use
in your WHERE clause) to see if that speeds things up. If it's a table
which you only read data from, you might want to look at keeping the
whole thing in memory - there are various options for doing this in MySQL.

The major disadvantage of splitting up the table is that you now have 10
tables to maintain - what happens if you need to change the schema at a
later date?

--
Paul Waring
http://www.phpdeveloper.org.uk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kieran Barnes  
View profile  
 More options Aug 26 2011, 8:36 am
From: Kieran Barnes <kie...@bloke.org>
Date: Fri, 26 Aug 2011 13:36:17 +0100
Local: Fri, Aug 26 2011 8:36 am
Subject: Re: [phpnw] Big look-up table question...
I agree with Paul Waring, 3 million records isn't a big deal really.
Your fieldset sounds quite small so if its read only, store it in
memory. And as Paul suggests, index your "where" column.

Modern servers with correctly configured fast disks, ie SAS or SCSI not
SATA and direct attached or large bandwidth iSCSI attached.

Theres much more to think about other than the query when your data is
getting large.

On 26/08/2011 13:30, Paul Waring wrote:

--
Kieran Barnes

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Goodwin  
View profile  
 More options Aug 26 2011, 8:57 am
From: David Goodwin <ginger...@gmail.com>
Date: Fri, 26 Aug 2011 13:57:31 +0100
Local: Fri, Aug 26 2011 8:57 am
Subject: Re: [phpnw] Big look-up table question...

On 26 Aug 2011, at 13:12, Paul Madley wrote:

> Hi,

> Not *quite* sure if this list is intended for asking this kind of question, but heh you're all experts :o)

> We're going to have a list of something like 3 million codes, each with an ID to the item in question, the date it was used, and a few other things.  Currently all in one (MySQL) table called... "codes"

> Now, can anybody see a practical advantage/disadvantage to actually having 10 (for example) tables, with an equalisish number of records.  As in, a table for codes starting A&B, C&D, etc etc.

> Basically; I wonder if the overhead of PHP deciding which table to query is greater than looking up the records in just one large table.  Any thoughts?

If it's slow, turn on MySQL's slow query log and have a look.
Check the output from 'explain select blah blah blah from codes blah blah blah'
Create additional indexes as necessary

Run http://mysqltuner.pl on the server - if you're using innodb then a major speedup can be had from increasing the default size of the innodb cache (which will reduce IO etc on the server) as it defaults to about 8mb. - running mysqltuner.pl will tell you lots of things you can change with MySQL.

David.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Madley  
View profile  
 More options Aug 26 2011, 10:08 am
From: Paul Madley <p...@sputnikinternet.com>
Date: Fri, 26 Aug 2011 15:08:26 +0100
Local: Fri, Aug 26 2011 10:08 am
Subject: Re: [phpnw] Big look-up table question...
Thanks for all the advice folks.  I generated 3,000,000 test (but valid) records and then write a quick script to look up a random 1000 in one go and it took > 0.002 seconds on my local machine, even with the rand() overhead.

So yep, cheers folks I think this is acceptable :o)

On 26 Aug 2011, at 14:01, David Goodwin wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Horst  
View profile  
 More options Aug 27 2011, 7:14 am
From: Ian Horst <ian.ho...@gmail.com>
Date: Sat, 27 Aug 2011 12:14:17 +0100
Local: Sat, Aug 27 2011 7:14 am
Subject: Re: [phpnw] Big look-up table question...
Hi Paul,

Nowadays a few millions rows are not really that much as people already
mentioned. We do handle millions and millions of raws.

Splitting table in multiple ones is not a good idea. Better consider to
use MySQL partitioning if you use MySQL 5.1 and up. You can take into
consideration the most used SQL queries to partition your table. And
performance boost is significant. Please read through
http://dev.mysql.com/doc/refman/5.1/en/partitioning.html to get an idea
what magic you can do.

Ian

On 08/26/11 13:12, Paul Madley wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »