473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MySQL Auto Increment

Hey,

I have a site that is about to go into production
and it has a couple of tables that it uses that
could get quite large once in full swing, most of
them have a column called "id" and it auto
increments every time a new row is added. When
setting this up, what do you recommend using at
the column type and size. atm I have gone for a
big-int with the size of 20. I wonder over time
will 20 be enough... Should I just think of a big
number and use it?

Anyone else in this situation and what would you do?
Aug 21 '05 #1
3 2142
"Smitro" <no****@myh0use.c0m> wrote in message
news:43********@quokka.wn.com.au...
Hey,

I have a site that is about to go into production
and it has a couple of tables that it uses that
could get quite large once in full swing, most of
them have a column called "id" and it auto
increments every time a new row is added. When
setting this up, what do you recommend using at
the column type and size. atm I have gone for a
big-int with the size of 20. I wonder over time
will 20 be enough... Should I just think of a big
number and use it?

Anyone else in this situation and what would you do?


BIGINT = (signed) -2^63-1 to 2^63-1 -or- (unsigned) 2^64-1, which in either
case is more than you'll ever need.
2^32-1 = 4,294,967,295 (4 billion 10 digits)
2^39-1 = 549,755,813,887 (549 billion 12 digits)
2^63-1 = 9,223,372,036,854,775,807 (19 digits)
2^64-1 = 18,446,744,073,709,551,615 (20 digits)

Storage size for BIGINT is 8 bytes, the size you are refering to (20) is the
size that MySQL would use to display the
number in the command line output. I don't beleive it has anything to do
with PHP (could be wrong).
Norm
---
FREE Avatar hosting at www.easyavatar.com
Aug 21 '05 #2
If you need to use a key larger than 18,446,744,073,709,551,615 you
will likely have other problems before you ever encounter a problem ---
I don't even know how to say that number :D

You are right to look to the future, but rather than worrying about the
key I would be inclined to start looking toward testing up towards the
limits of the application to see if it is even functional and start
working backwards from there. Maybe work out how much storage you are
going to need for indexing .... I love MySQL, I really do but I worry
about huge huge databases in anything but Oracle, its slower on smaller
databases but when it comes to handling billions of records and
actually managing a database contraining kazlillions of records its
tools and functions reign supreme -- and frankly so does the
performance (in my experience** couch couch**)

Aug 21 '05 #3
Smitro wrote:
I have a site that is about to go into production and it has a couple of
tables that it uses that could get quite large once in full swing, most
of them have a column called "id" and it auto increments every time a
new row is added. When setting this up, what do you recommend using at
the column type and size. atm I have gone for a big-int with the size of
20. I wonder over time will 20 be enough... Should I just think of a big
number and use it?


Define "could get quite large"? If you have a system with, say, 100
queries/s (not a bad load already), then:

100 * 3600 * 24 = 8'640'000 records / day

An unsigned int (which I usually use myself for these kinds of
fields) is 4294967295, so with that kind of load you will run out of
id's in... about 1.4 years. However, 4 billion rows is already quite a
large table. Are you really going to get anywhere close to that?

/Marcin
Aug 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sugapablo | last post by:
Let's say I create a new record in a table like this: mysql_query("INSERT INTO table (col1) VALUES ('example')",$conn); ....that had an auto-incrementing, unique identifying column named "ID"...
19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
2
by: shoa | last post by:
Hello I can link MS Access (front) with MySQL (back end). However, when I add a new record, the previous added record is signed as Deleted record (view in Access) even I can view this record in...
1
by: Ward B | last post by:
Greetings. I'm somewhat new to this whole MySQL/PHP thing and need a little help. My web hosting service uses phpMyAdmin and at the bottom of the screen iis an area where I can upload a text...
1
by: Smriti Dev | last post by:
Hi There, I hope you can help with this problem I have been having. I have linked tables from a mysql database and an access database. One of the fields (my primary key field) is an auto...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
13
by: miker2 | last post by:
HI, I'm having trouble writing to a MySql db using python and the MySQLdb module. Here is the code: import MySQLdb base = MySQLdb.connect(host="localhost", user="blah", passwd="blah",...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
0
by: vanisathish | last post by:
Hi, I'm facing a strange intermittent problem. I've my mySQL server running & another process updating a table continuously. One of the field in the table is Auto-Increment. When my PC is...
1
by: cool84 | last post by:
hai, 1. i need help on how to set the auto incremental as "REF0001","REF002","REF003",.......and so on. 2. i declare the field as integer but i want the prefix "REF" follow by the ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.