Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Would MySQL Handle Millions Of Records Tables


I already found on the MySQL web site that some users did have good
results with tables of some millions records.

But, what I want to do is store some hundreds millions records in a
table. 190 millions to start and maybe a lot more after. Does someone
already use MySQL with such a quantity of data ?

I was also asking myself how a simple SELECt query like this one below
would perform on such a table.

SELECT * FROM MyTable WHERE MyPrimaryKeyField = Value;

I think that with indexes this shoudl be fast despite the fact that
the table is huge.

An other kind of query i'd like to do is :

SELECT Count(*) FROM MyTable WHERE ABooleanField = True;

I expect this one to take several minutes, maybe hours. Is my guess
right or could it be lot faster/slower ?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Optimizing Slow Queries On Millions Of Records
I have a table that has millions of records in it.
About 100 records are added every 5 minutes (one per OIDID) (the sample
provided below has data for 2 OIDIDs (99 and 100)
And I have a webpage that executes 9 queries one after the other, and then
displays the results on the webpage.

When the database was empty, this process was very quick.
But, as the DB grew, it became slower.
Now it takes about 38 seconds for all queries in the example below.
MySQL 4.1 on Windows

I have tried different indexes, and they do help and are used, but the
queries still seem to take a long time. Code:

How Can I Handle The Referential Integrity Y MySQL Tables?
How can I handle the Referential Integrity y MySQL tables?

1 Table For Millions Of Rows
I have one table which may record possibly millions of hits and i want to know if this is a good idea?

Optimizing Search Query For Millions Of Rows
I have mysql 4.1 and Im having a difficult time optimizing this query.

select domain, length(domain) as len
from domains
where
length(domain) <= &#3916;' and
not (domain regexp '[[:digit:]]') and
domain not like '%-%' and
price > &#390;' and price < &#3916;' and
end > &#55614;&#57159;-12-01'
order by end ASC, len ASC
The following query outputs:


| id | select_type | table | type | possible_keys | key | key_len | ref | rows | extra |
-------------------------------------------------------------------------------------------------------------------------------------
| 1 | SIMPLE | domains | ALL | end | NULL | NULL | NULL | 2600000 | Extra where; Using filesort |
My indexes are:
ID - PRIMARY, Unique
domain - Unique
end

Is there anyway this query could be optimized anymore? With only 2.6 million rows its taking a 5 or 6 seconds. It looks like its not finding the right keys.

Can't MySQL Handle Images
I would like to include images in MySQL database to advertise for my products. Is this possible? ... but it must be! I see it used on the Internet all the time. How can I include images in the database?

MySQL Handle Arabic
I am trying to load Arabic characters into a MySQL table, and it doesn't appear to be working. The database is in XML format. When I look at the file using an XML viewer, the Arabic characters are there. I then use Navicat to import the XML file into MySQL. When I look at the file with MySQL query browser, there are question marks where the arabic chars should be. If I export the MySQL table to Excel (which I know can display Arabic chars) ther are still just question marks, so somehow I am losing the chars in the conversion.

How Many Rows Can Mysql Handle, How Much Text Can Fit
How many rows and columns can mysql support? does it vary depending on amount of info in each row/column?

also, how much text (characters) can fit in a text field?

and lastly, i have a list of rows and need to display based on most recent date (sorting further by time if multiple entries on same date)...

i have this to sort by a column by a-z or z-a:

"select forms from formList where formID = '' order by formName desc"

How Many Connection Can A MySql Database Handle Per Second.
I am using a MySql database for chat application.

Every 3 seconds the database is searched for various details.

I would like to know How many individual can it handle at a time.

Say there are 6 users each making a call in 3 second So every second 2
connections are made to database.

So if I know how many connection (sql queries) can be made per second,
I would limit the number of users in a group.

Mysql Version Is More Able To Handle Heavy Traffic
we are currently running mysql 4.1. we have problems with a php/mysql website that generates a lot of traffic and relies heavily on mysql (it's a "find your old schoolmates" community website).
Sometimes it just says "too many connections", or just takes a long while before rendering the page.

Would upgrading to mysql 5 help ? What are the best mysql settings in order to optimize the performance?

Maximum Allowed Tables/db, Fields/tables, Records/table
1)tables that can be created in a MySql database.
2)fields that can be created in a MySql table.
3)records allowed in a MySql table and in a MySql database.
4) allowed joins in a MySql table/database.

Count Records From Two Tables
I have two tables and I want to count the number of records where field1 = 1.

tbl1    field1
           1
           2
           1
           0

tbl2    field1
           0
           0
           1

Result should be 3

Can someone help with the right coding?

Transfering Records Between Tables
I have two tables 'gamestats' and 'gamestats_archive', i want to move x records from gamestats to gamestats_archive and then delete the records that have been moved from gamestats.

Here is the queries that I am using:

first this runs:

INSERT INTO gamestats_archive SELECT * FROM gamestats WHERE date='$selecteddate' ORDER BY entry_id ASC LIMIT $maxstats

then this one:

DELETE FROM gamestats WHERE date='$selecteddate' ORDER BY entry_id ASC LIMIT $maxstats

the problem is that the delete query is not deleting the records that have been moved, its deleting different ones. does anyone know why this might be happening?

How Count Records From Two Tables?
I’m having two tables: ap_author and ap_books. I wont count how many records have everyone authors in table ap_books.

ap_author ------------------------------
| author_id | first_name | last_name |
| 1 | first1 | last1 |
| 3 | first2 | last2 |
| 4 | first3 | last3 |
--------------------
ap_books-------------------------------------
| book_id | title | author_id | total_pages |
| 1 | title1 | 1 | 2 |
| 2 | title2 | 1 | 5 |
| 3 | title3 | 4 | 1 |
--------------------

I use this query: SELECT ap_author.author_id, ap_author.first_name, ap_author.last_name, COUNT(*) AS books FROM ap_author, ap_books WHERE ap_author.author_id=ap_books.author_id GROUP BY ap_author.author_id

This query returns only these authors, which have one and more records in table ap_book. How I’m can get all author?

Records From Linked Tables
can anyone help me with an sql statement that will work for mysql to take data from two tables where the two tables are linked with a common field.

Query Total Records In 1 DB With 5 Tables:
In PHPmyadmin there's an option that shows you the amount of records in all tables, how can I did this via a query?

Deleting Records From Multiple Tables
I'm trying to delete an article and the corresponding comments to this article

articles
+------------+
| article_id |
+------------+
| 13 |
+------------+
| 16 |
+------------+

comments
+------------+--------------------+
| comment_id | comment_article_id |
+------------+--------------------+
| 1 | 13 |
+------------+--------------------+

mysql_query("DELETE articles, comments
FROM articles, comments
WHERE articles.article_id = 16
AND comments.comment_article_id = 16");

Because article 16 has no comments, the article doesn't get deleted. If I try to delete article 13, this will work.

So how can I delete article 16 even if there are not any comments at all?

Counting Records In 2 Tables Using 1 Query
I have these 2 queries.

SELECT count(*) gifts
FROM gift g
WHERE g.this and g.that

SELECT count(*) events
FROM events e
WHERE e.this and e.the other thing

is there a way to put these into one query.....

SELECT count(g.*) gifts, count(e.*)
FROM gift g, event e
WHERE . . . .

so far nothing seems to be working .....

Join 2 Tables And Limit Records From One
i've got 2 tables:

Gallery
Gallery_Id,Gallery_Name

Images
Images_Id,Gallery_Id,Images_Filename,Images_Width,Images_Height

I'd like to select all galeries from Gallery and join Images to each gallery but i'd like to limit 3 images per gallery this code list all images from all galleries, i suppose that i must try with subqueries, am i wrong ?

SELECT a.Gallery_Id,a.Gallery_Name,b.Images_Id,b.Images_Filename
FROM Gallery AS a INNER JOIN Images AS b ON b.Gallery_Id=a.Gallery_Id

Time Difference Between Records From Two Tables
I have two tables with data from two separate data loggers. The timestamps of the records are not perfectly synchronised (eg. 2005-07-11 22:50:00 and 2005-07-11 22:49:58). All data must be joined to one table and all records that are out of sync by more then 30 seconds must be rejected. I tried somethig like this: Code:

How Do You Handle Birthdays In A Db?
I'd like to be able to gather a child's birthday and then use PHP to retrieve the birthdate from the db and automatically update the age as time goes by. What do I enter in the db and how do I do it?

Handle Use By Mysqld.exe
When I run MySQL, I notice that mysqld.exe uses > 40,000 handles (according to Windows Task Manager).Is this normal? what all these handles are used for?

Can't Update Records When Using Linked Tables In Access
I have a linked table to MySQL 5.0 through MS Access 2003 that utilizes a timestamp field in order to prevent the #Deleted signature happening everytime I create a new record. However, when I attempt to update a previous record I receive the error message: "Reserved error (-7776)" and am subsequently prevented from updating any records. Please note, there are no errors when creating new records, only when I attempt to update an existing one. However, if I remove the timestamp field, updates occur without error. Has anyone else encountered this issue? How might I rectify it?

Join 2 Tables And Select Only Most Recent Records
I have been wrestling with a way to select only the most recent records for a group of clients without using a subselect. I have two tables: cdp_clients and cdp_level_records related by 'admitid'. For each cdp_client there are multiple cdp_level_records, each with a different 'level_date'. I want to select only the most recent cdp_level_record for each client in cdp_clients.

Join Tables To Count Number Of Records?
I've two tables:

responses
==========
response_id
schema_id
timestamp

answers
==========
answer_id
response_id
answer

(that's a cut down version, but will do for this question)

I need to get all the responses where there is at least one answer in the answers table. But I do not want the answer data. It's literally a quick check for an export to say "get me all the responses where there's at least one question answered". I have this: Code:

Get List Of Tables Containg Specific Records
I have a database with 20+ tables that contain data from various instruments. Samples can be measured on any combinaiton of instruments and I would like to be able to query the database to find which tables have data for a specific sample, with the table names being returned to build a dynamic web form for selecting and viewing data.

I can build sort of brut force queries via php to do this to mitigate re-writing webpages when additional tables are added, but it seems to me there should be an elegant solution (or at least brut elegant) to this.

Copy Records From Tables To Remote Database
there ara two mysql server server1 and server2. server1 ip adress is 192.168.1.2 and
server2 ip adress is 192.168.1.3. both servers have same database. i want to copy records server1 to server2 have can i do this?

How To Handle DHCP And Permissions
I am using an Access front-end, but the users are on machines set to DHCP. SO when the IP changes, they are denied access.

How Database Handle Request?
I want to write a program that can access to multiple database based on the user ID, but I dont know how the database handle user request. Please help me...

if user A execute program and redirect to database abc, and user B also accessing it. user A retrieve value from database but not yet update it, at the same time user B go get the value. How can I control it? can I code a program that control if A not yet finish, we cannot allowed user B to retrieve the value?

I cannot use Java synchronization. if I use it, it will synchronize for all the request although the request is redirect to different database(I am using many databases but sharing 1 program). There is no point to do synchronization if another user accessing other database that is no user at that moment but still need to wait user at different database finish their tasks first.

How To Handle Multilingual Content ?
I have a small cms and now there is the need to store foreign content (japanese/farsi) in the database. I use standard Tiger X-Serve with PHP5 and the preinstalled MySql.

And now I need a little help with the foreign language support. The things I did already:

1. I put »charset=utf-8« in the HTML meta tag.
2. I use phpMyAdmin and set the database language collation to »utf8_general_ci«
3. I copy/paste a japanese text from apple.co.jp into my formular and tried to store it into my database.

But it seems that is not enough

Does anyone know how to solve my problem?

How Database Handle Request?
I want to write a program that can access to multiple database based on the user ID, but I dont know how the database handle user request. Please help me...

if user A execute program and redirect to database abc, and user B also accessing it. user A retrieve value from database but not yet update it, at the same time user B go get the value. How can I control it? can I code a program that control if A not yet finish, we cannot allowed user B to retrieve the value?

I cannot use Java synchronization. if I use it, it will synchronize for all the request although the request is redirect to different database(I am using many databases but sharing 1 program). There is no point to do synchronization if another user accessing other database that is no user at that moment but still need to wait user at different database finish their tasks first.

Handle Line Breaks
I want to save textarea contents to a mysql database with the
paragraph breaks intact without having to type paragraph or break tags
in HTML. How can I do that. So far, although it occurs naturally when
I save the contents to a file, it doesn't break up the paragraphs
properly when I save it to my database.

Handle Old Or Disabled Data
I have a table of profiles that users create (they can create more than one). At some point, they may want to delete that profile, however, we don't want to delete the data, we'd rather disable it. (the info will be important to us later down the line).
I'm not sure which is the better option:
A. add a status column to the 'profileList' table and when they want to "delete" the alert profile, I just set the status to: 0?
B. create a second table with the same structure called "profileList_Archive" and insert the disabled row into that table first then delete it from the live table?
Just wondering if all those disabled alerts in the same table as the active alerts will cause performance issues down the line. This table will be probably(hopefully) have grow very large over time.

How To Handle Duplicate Keys In Insert
I have the following table definition:

CREATE TABLE `suggested_synonyms` (
`Last_Name` varchar(255) NOT NULL,
`Synonym` varchar(255) NOT NULL,
PRIMARY KEY (`Last_Name`,`Synonym`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The table stores mapping from a last name to a synonym.
I need to insert multiple rows into the table. Something like:

insert into suggested_synonyms (`Last_Name`,`Synonym`) values ('smith', 'smeeth'), ('smith', 'smeath');
the problem is that some of the mappings may already exist in the table.
I tried to use the ON DUPLICATE KEY UPDATE syntax to prevent duplicate entries, but apparently I am not doing it correctly:

insert into suggested_synonyms (`Last_Name`,`Synonym`) values ('smith', 'smeeth'), ('smith', 'smeath') ON DUPLICATE KEY UPDATE;
As I need to specify the columns to update.

Is there a way to insert multiple rows in a single query and still be safe from duplicate rows?



Handle No Data Found Situation
I am kind of new and am trying to set up error handlers in MySql
5.0.41.
I create a function. Within, I try to keep selecting until I get
nothing back from select.

I cannot seem to catch the error when the select returns nothing.
I declare a handler like this:
DECLARE CONTINUE HANDLER FOR NOT FOUND
BEGIN
SET tester = 01;
more stufff....
END;

DECLARE EXIT HANDLER FOR SQLWARNING
BEGIN
write out to error log...
END;

Then, I have a loop like this:

myloop: LOOP

select x INTO y
FROM z
WHERE a = b;

if tester = -1 then
LEAVE myloop;
end if;

do stuff here....

set b = b + 1;

END LOOP myloop;

The select is guarenteed to retrieve nothing after a few loops around.
but it never ends. The declare continue handler does not fire.

If I run from client command prompt the EXIT handler fires, but I
dont get the warning message, just message thatit exited without a
RETURN.

If I remove all error handlers and run form prompt, it runs endlessly
until I stop it with a counter var. Then I get X number of warnings,
but it doesnt say what the warning is

Handle Time Stamp With Milliseconds.
Right now I am working with PostGreSQL. Now I am planning to migrate to MySQL.I am having the field with data type 'TimeStamp' in PostGreSQL.Which stores the date , time along with the milliseconds.When I am trying to use same datatype in MySQL, Timestamp is not allowing to store milliseconds.Is there any alternative to solve this problem.

Proper Way To Handle Old Or Disabled Data?
I have a table of profiles that users create (they can create more than one). At some point, they may want to delete that profile, however, we don't want to delete the data, we'd rather disable it. (the info will be important to us later down the line).

I'm not sure which is the better option:

A. add a status column to the 'profileList' table and when they want to "delete" the alert profile, I just set the status to: 0?

B. create a second table with the same structure called "profileList_Archive" and insert the disabled row into that table first then delete it from the live table?

Just wondering if all those disabled alerts in the same table as the active alerts will cause performance issues down the line. This table will be probably(hopefully) have grow very large over time.

Handle User Credit Card
I'm setting up a site on a shared server that allows users to buy a single product with their credit card. SSL will be used for encrypting the data sent between server and browser, but my question is what to do with the credit card details once they're sent to the server.

Storing them in a database isn't ideal from a security point of view. But the details have to be stored somewhere (for a short time at least) as the site will not be availing of any credit card authentication services when the transaction occurs. The company has their own credit card machine in the office which they manually use to complete the purchase, so they need to be able to reference the card details.
So what are my options? Some form of encryption?

Handle Replacing ' In Data Already Input
I have recently been given a project that belonged to another programmer.
The issue I'm having is that no data validation was put in place of the program and so now I have data that has characters that are not allowed by MySQL, specifically apostrophes.
I now how to do it in PHP to replace the character, but what I need to do now is to replace the data already in the table. I'm specifically talking about a user's login name.
Can I escape it inside the database and not have the user's login name change?
For example I have a username that is O'LearyDM.
I haven't been able to comb through all the code to figure out just how the original programmer was able to even allow insertion of apostrophes, but now I need to fix it.

1 Line Query To Delete Specific Records From Multiple Tables
On clients machine, currently to delete on trainee record it runs 10 queries to delete records from 10 tables. At the time of running all queries, server shows (104) Connection reset by peer. An error condition occurred while reading data from the network.

I think it because of running 10 queries at a same time. Is there any possibility that through one line of query we can delete record from 10 tables.

I've tried following query

DELETE FROM table1, table2, table3, table4, table5, table6, table7, table8, table9, table10 WHERE empID = 11;

But it gives ' error in query.

Handle Duplicate Log Entries (but With Differnet Timestamp)
I am logging page views into a table. In some cases there may be many entries that all have the same values across the board, except for the timestamp. I would like to be able to remove the duplicate rows, or consolidate the dupicates. I haven't found any specific tool to do this. What would be the most efficient way of doing this? As an example, if a the home page is viewed by the same person 5 times in a day, or an hour, I'd like to only end up with one entry.

How To Handle Line Breaks When Storing Textarea Entry In A Database?
I want to save textarea contents to a mysql database with the
paragraph breaks intact without having to type paragraph or break tags
in HTML. How can I do that. So far, although it occurs naturally when
I save the contents to a file, it doesn't break up the paragraphs
properly when I save it to my database.

Count Related Records, But Show Records With NO Related Records Also
cl_items
========
it_id (pk)
it_ownerid
it_name

cl_offers
========
off_id (pk)
off_itid (fk) -> to it_id
off_whoid

My query needs to output ALL of the records in cl_items AND still show how many offers are on each item (from cl_offers)

I can't get what I want through the GROUP BY because I want to show the records in cl_items which DO NOT have any offers on them yet also.

Is there any way to do this with mysql only?

All Records From Table A - All Records From Table B - Join Alike Records
I am by no means a SQl Jedi as will be apparent by my question, but I
can usually figure out a select statement on my own. I have one today
though that really has me stumped. I am working in MySQlL 5.

In My first select statement I get all my records from Table B
SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`
Inner Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`

In my second statement I get my records that match in this case phase
401 in Table B and all my Table A records for phase 401.

SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`

Left Outer Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`
Where
table_A.PHASE In ('401' )

Now I need to combine the Data of both recordsets. I need EVERYTHING in
Table B, but I also need All Table A records that match the phase
selection....

Can I write this one query or do I need to use a Temp table?

Delete Records Without Matching Records
I have a one to many relationship in my database. I would like to delete records in one table if there are no matching records in another table.

1 Mil.+ Records Ok For Mysql
this may be a dumb newbie question, but I didn't have any db with such massive content.
I need a DB to hold more than 1.000.000 records with various information and details.
The mysql DB (4.03) runs on a server along with an apache installtion to serve Web requests.
Is mysql able to handle this amount of data???

Keep Only 50 Records In MySQL
Does anyone know how to keep only 50 records in a database table?
Can mysql automatically do this or do I have to write php to do it for it.
i.e. if there are the id goes from 23 - 53 when a new row is added it gets id 54 and id 23 is deleted?

How To Get Last Week Records In Mysql 3.0.x
How can I get all records relating to last week from a table . I am using Mysql 3.0.x.

How To Exclude Particular Records In MySQL?
My PHP script has a SQL statement as shown below that works fine, but it is slow and inefficient. I need to speed it up by using one sql statement instead of using the sub-query.

The solution I need is to eliminate the use of the NOT IN clause ie

SELECT DISTINCT CONCAT(fname,' ',lname) AS realname, staffid
FROM staff
WHERE team = 'umi'
AND staffid NOT IN (SELECT staff.staffid
FROM staff, calendar
WHERE calendar.staffid = staff.staffid
AND calendar.type IN ('arl','lsl')
AND (calendar.start BETWEEN '$begin' AND ADDDATE('$begin', 6)
OR '$begin' BETWEEN calendar.start AND calendar.end)
)

where $begin is a PHP variable that has a value like this '2007-11-20" etc. What I want is that it excludes staffid that is already defined in the calendar table by start and end fields. I tried to make it more efficient, but I could not solve.

Editing Records In Mysql
I have downloaded the MySQL Administrator and MySQL Query Browser GUIs for Windows.  What I really want to do is just edit records visually without having to type SQL queries.  I thought for sure one of these two programs would allow me to do that, but I don't see where. 

I see how I can access databases ad and edit table information, but I don't see where I can go into a table and actually ad or edit a record without having to type SQL commands.  Am I missing something, or is there some other free program available that will allow me to visually edit records (that is, from Windows...I don't want to use phpMyAdmin)?  I can't imagine something like this doesn't exist for such a great database system as MySQL.


Copyright © 2005-08 www.BigResource.com, All rights reserved