Speeding Up Large MySQL MyISAM Tables
I'm somewhat new to MySql. I've been using it for a while, but pretty much
out of the box setup, and am starting to suffer heavily with my larger
tables. I have a table with 5,000,000+ rows that I have to search and do
joins on. Although I have an index set up for it, the joined select will
still take some 400+ seconds to return, which is obviously unacceptable.
This is due to enormous HD access.
Perhaps someone can help me with indexes here; I was under
the impression that the index for the tables are cached in memory, and
therefore permitted "instant" searchability, without having to retrieve data
from each of the rows of the DB. Is there a startup parameter, or
something in the mysql.ini file, that must be set to allow for this? I have
the index configured properly, and have made sure that the query uses there
parameters in the where clause in the same order that they appear in the
index. Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Index For A Large Myisam Table (MYD ~=7GB, MYI ~= 7GB)
I have a very large table with 66,836,760 rows (in my world), MYI and MYD files each about 7GB in sizes and even though I've created indexes for all the possible columns, some queries are still slow. I think I read somewhere that for a very large table, there is a way to configure Mysql to store the index file separately just for that table to facilitate the query. How do I do that?
View Replies !
Optimizing Mysql For Large Tables
I have been working with Mysql for about 5 years - mainly in LAMP shops. The tables have been between 20-100 thousand records size. Now I have a project where the tables are in the millions of records. This is very new to me and I am noticing that my queries are really slowwwwww! What are the options that I have to speed my queries on the mysql side with regards to the my.cnf file. I have a fair understanding of sql optimization and I understand explain. I just want to see if there is something that I can do with the server also.
View Replies !
InnoDB Tables And MyISAM Tables In ONE Database?
My application demands some advantages from InnoDB and some from MyISAM. Is it attainable to have both InnoDB tables and MyISAM tables in ONE database? Or else, getting views from two databases, one from InnoDB and the other from MyISAM? If not possible, any other approaches will do the job?
View Replies !
Speeding Up A Like Name ='%%' And Name ='%%' Query
I've built myself a Impartial Price Comparison site using a feed from a provider. It all seems to work fine although it is slow at times. So i've decided to go on useing a database. But i cant seem to get the queries fast enough to warrant the switch. if i do the following query: Code: select * from {table} where ( name like '%ipod%' and name like '%touch%' ) limit 20; The database has 707K rows all with product information. The above query takes 38.81seconds. If i do it with only one like then it takes about 0.3s. So i know the indexes are setup ok. (or at least i think so) Is there a good way for me to do the above query much faster?
View Replies !
Making All Tables MyISAM
Is there a way to specify MyISAM for all tables in a given file rather than having to specify it at the end of each table declaration. I think this would make porting databases back and forth to MySQL somewhat easier since including MyISAM as part of the table declaration is not compatible with standard SQL syntax, so I would like to keep MySQL-specific stuff separate from the rest of the SQL DDL file.
View Replies !
Speeding Up Lookups On A Table
I have a MySQL query running inside a CGI script on my site that, at random intervals, seems to take 10-20 seconds to complete instead of less than 1 second. I spent so much time trying to track this down that I wrote a script which runs once a minute on the site, which (a) captures the output of "ps auwx" (listing all processes) so I can see if that has anything to do with the slowdown; (b) times how long it takes to run the query, and; (c) times how long it takes to run a similar query on a much smaller table. (Part (c) is so that I can separate out whether it's the size of the table in part (b) that's making the difference, or the time taken to do something that's common to both queries, like getting a database handle.) 90% of the time, the large-table query takes less than 1 second, but 10% of the time, it takes 15-20 seconds. (The small-table query always takes less than 1 second.) I looked at the output of "ps auwx" to see if there seemed to be a relationship between the %CPU time used by other processes, or the number of other running processes, and the speed of the query, but there didn't seem to be. Code:
View Replies !
Speeding Up Index Creation
I have an innodb table with 2.5 million rows. I'm trying to create a multi-column primary key on two columns, however it's taking a very long time. I haven't actually seen it finish yet before I've killed it. (Sometimes after an hour not finishing). When I run SHOW PROCESSLIST, it says under state, 'copy to tmp table'. Previously while working with big tables I remembered it always taking a long time during the 'repair by sorting' stage, I don't even remember seeing the copy to tmp table part.
View Replies !
Speeding Up Searches With Indexes
I want to use indexes for a table I need to search but I'm getting really confused as to how to do it. :confused: The table is like so: +-----------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | | PRI | NULL | auto_increment | | title | tinytext | | MUL | | | | star | text | | | | | | synopsis | text | | | | | | label | tinytext | | | | | | format | tinytext | | | | | | price | float unsigned | | | 0 | | | thumbnail | varchar(34) | | | | | | fullSize | varchar(34) | | | | | | genre | varchar(20) | | | | | | subGenre | varchar(20) | | | | | +-----------+------------------+------+-----+---------+----------------+ I only need to search title, label, star, genre, and subGenre. Should I be making one index for each of those columns?
View Replies !
Changing Tables From MyISAM To InnoDB
I have a database with about 20 or so tables, maybe a few thousand rows in each. I am starting to do more complex things with my insertions etc, and I want to start to use transactions, so I imagine I should change some table types in the database from MyISAM to InnoDB. I know that InnoDB tables are a completely different beast than MyISAM in terms of data storage etc... ie: instead of using folders on the server, everything is stored in a file (ibdata1). Is there anything I should be aware of when changing a bunch of tables from MyISAM to InnoDB? Any hidden gotchas like changing 'ibdata1' in any way, table slow downs, index changes, or ANYTHING? Or can I just alter the tables and go on my merry way? Something tells me I need to start learning a bit more about that ibdata1 file.... is there a size limit or anything? It seems to me that because MyISAM stores its data in directories on the server, that accessing the data would be much quicker. Having all my data in that one file seems like it would slow things down... does it?
View Replies !
Differences Between Myisam And Innodb Tables
what is the difference between myisam and innodb tables ?? And why is there a comment "innodb free: 4096 kb" since I have changed my tables from myisam to innodb? Is this working like Sybase, where you need to create devices for data storage, or do I miss the idea completely here?
View Replies !
MyIsam Tables With 1 Billion + Rows
We have an application that requires two MyIsam tables each with 1 billion+ rows. This data is historical. Can MyIsam handle such large volumes of data? Should we use partioning or merged tables?
View Replies !
About Exporting MyIsam Tables (Vista To Web Ed. 2003)
I run MS Server web edition 2003 on a collocated server with IIS 6, PHP and MySql 5.0.x. On a regulary base I add records to my databases. Therefore I have my complete web site with the database on my laptop. Laptop is running on Vista and IIS 7, using MySql 5.0.x. First I add my new data to my database on my laptop and when all seems ok, I upload the MySql data-files to my server. Now i do this already for years on a – may be – strange way ... As i have all my tables in the form of MyIsam, I always have 3 files for each table ...
View Replies !
Speeding Up Boolean Search Control Syntax
When doing a FULLTEXT search on a table I have noticed that on average introducing wildcard boolean search control syntax slows down searches by up to 10-20 times longer than without it. For instance, if I want to search for both "keyboard" and "keyboards" so I perform a match against 'keyboard*' then just making that "s" optional takes my previously 0.08 second query to 2.6 seconds. Is there any way to speed up MySQL 5.0 so that such simple touches for improving result relevancy doesn't cause such a drain on the server and our visitor's patience?
View Replies !
Large Tables
So i've got a table with 15 million rows. id is the primary key SELECT COUNT(id) FROM listings WHERE id != 0; Takes about a minute to load... which is insanely slow.. anyone know what could be causing this?
View Replies !
Very Large Tables
I am looking at using mysql to store some particle physics data. So the idea is (for example) I would have a table with a list of events, then a table with a list of particle types (one event can have many particles) and so on. The problem is that quite often I want to calculate something for every single event, but this table might run into 10s of millions of events and many GB. Obviously it would be mad to load the whole result set into memory then iterate over it. My question is: is there any way to have the db push results to the users one (or a few) at a time in an effiecent way? I was thinking of something like an iterator that pulls the data from the disk one (or few) at a time. An alternative (but much less useful) method might be to hand the function I want to calculate to mysql, for example: select myfunc(x,y,z,a,b,c) from events where energy>3; But as far as I know there is no way of defining your own functions in SQL
View Replies !
Large Table Or Many Tables?
I posted a similar question about 6~12 months ago with no definate answer, so I will give it another go, as the choice has popped up again in my programming life: If the number of entries is the same is it more efficient (better) to have a single table with many columns, or many tables with few columns? The obvious answer is a single table, because there is less closing and opening tables, but the reason why I ask is what about searching through a lot of columns being even more inefficient? The situation is I need to record data for every week of the year. Say ~50 columns per week --> 2600 columns. Or, do I split it so it's 52 tables with 50 columns each? In each of these options the user (or user ID) will be the primary key. The seemingly pointless other option is to insert new columns with every new user, and have the week-item as the primary key?
View Replies !
Large Number Of Tables
I would like to ask whether it is feasible (or whether it makes sense) to run a PHP script that creates a number of tables for each user. Basically, this script allows users to sign up for a free service, and for each user that signs up, the script creates 9 tables in the database to contain that user's details. Is this a sensible way of containing user data, and what are the inherent problems this may cause especially when say are 1000 users signup?
View Replies !
Large DB Should Use Multiple Tables?
I have a social networking site similar to myspace, currently my table which links who is who's friend on my site is 2 weeks old and is at 300,000 rows but is only at 15mb in size, this is the most accessed table of all my tables. My question for performance, as this table grows should it eventually make a new table? If so here is my current select code select userid,friendid,status from friend_friend where userid='$temp[auto_id]' and status='1' Could someone give me an example of how o select this from multiple tables if I add more for this table in the future?
View Replies !
Managing Large Tables
I recently inherited a database (version 5.0.18) that has 1 table constantly growing out of hand between 10GB -30GB, therefore making is difficult/impossible to query. Also, the Archive Storage Engine is not installed. Currently, the table is manually renamed (i.e. tablename_daterange) and a new table created. ....
View Replies !
Join Tables On A Large Database 200 Meg
i am trying to work out the most efficient way to list say multipl= e categories of entries, the database is quite large about 200 meg.=20 I would like to know if using join tables is more efficient than storing th= e keys in a varchar field then within the second loop doing a where in (1,2= ,3,4) where the 1,2,3,4 are the stored category keys in the varchar field = rather than a where in (1), where 1 is the pirmaryID of the entry for insta= nce ?
View Replies !
Slow Join On Large Tables
I have two tables: D (500,000 recs), and DL (2,500,000 recs) D has a PK and an index on HLQ. DL has a PK and an index on ID. The following SQL: SELECT HLQ as "HLQ", count(*) FROM D, DL WHERE D.DLID=DL.ID GROUP BY HLQ produces the following explain: tabletypepossible_keyskeykey_lenrefrowsExtra DALL500000Using where; Using temporary; Using filesort DLeq_refIDID4D.DLID1Using index The query takes ~ 3:30 on a Athlon xp2200; 1GB RAM; default bufer settings. Adding the following buffer settings only slightly decrerased the time (~3:00). key_buffer=512M table_cache=256 sort_buffer=16M read_buffer_size=16M It appeasrs that the 'Using filesort' on table D is due to the Group By clause and is the problem. I have an index on HLQ. Is there any way to get MySQL to use it?
View Replies !
One Large Table Or Many Small Tables?
I'm trying to decide whether to use one large table or many small tables. I need to gather information from various devices (about 500). Each device has its own Id and some data. Should I use only one table with an indexed column for the ID and another column for the data, or should I use 500 tables each with only one column for the data?
View Replies !
Large Tables, Very Slow Deletes.
I've been using MySQL for a while now and are starting to run into limitations. Either my own, or something else. I have this really large table, it stores images, it has a mediumblob field, an unsigned id integer field and a timestamp field. This table contains up to a few million rows and is constantly filled real time. It grows up to sizes between 50 and 100 gb and in the future probably even larger. This data is not supposed to be stored for all time, therefor when a certain treshhold is reached, the oldest 5000 rows are deleted to make room for newer rows. This is where my problem kicks in. Whenever I try to delete those rows, it can take for ever to complete. 500 rows I can delete without problem, 2500 becomes slow, 5000 rows takes several seconds and 10.000 rows or more makes it looks like things are frozen. Now the temporary solution I have is to delete 500 rows at time, but this means I must do that every 10 seconds just to maintain status quo. I would much rather check every 5 minutes or so, and if needed delete 15.000 rows in one go. I use MyISAM tables and tried setting the key size to 128M, no luck. I run this on a dual Opteron system with a GB of memory and WinXP-SP2 Proffesional.
View Replies !
Large Unused Tables Vs Performance
I've been working on a website with a rather large a database. One of the about 100 tables in there was about 1/4 of the total database size. The table had no use anymore at the time I worked the website, so it was just sitting there, doing absolutely nothing. Obviously to spare diskspace we deleted the table. But the question I have now, can unused large tables affect the perfomance of Mysql? I've searched a bit around, but honestly I couldn't find a clear answer about it right away (maybe I haven't searched enough either :) )
View Replies !
One Large Table Vs. Many Small Tables
I'm working on a design using PHP & MySQL and I'd like to get some opinions on this. My design has several tables that will be referenced but I'm wondering if those tables should be broken down even more and referenced more dynamically. The reason that I wonder about this is for long term goals. I hope that eventually there will be two or three thousand records that will be used on a regular basis. These records will need to be separated into groups, but I'm not sure if I should use a field in the database table or create a new table for each group. If a few hundred records could be in each group, do you think it's better to use one large table with a field for the group ID, or a new table for each group?
View Replies !
Large Number Of Tables And Columns
i'm developing an online portal, which my MYSQL database contains 100 tables.. my doubt is if any table contains 30-40 columns will it become a problem? like my html front end form has 40 fields for data insertion. and i'm not maintaing any duplicate data if my DB contains 100-150 tables will it create any problems? as i'm inserting data from EXCEL via PHP to MYSQL, please suggest me whether a healthy MYSQL table is dependent or independent on NO:OF COLUMNS(FIELDS) or not?
View Replies !
Can I Replace Corrupt MyISAM Tables By Just Copying Files From A Backup Directory?
I have a myisam table with about 1.9 million rows in it. This table has been badly indexed. An Atmysqlt to build a new index failed and the table (I suspect the myi file) has corrupted. Fortunately this occurred on a beta site. Unfortunately this is on the same server as the live site (no budget for a beta server) I can't shutdown the database server to atmysqlt a repair. Can I just copy the files back from the backup? How can I build this vitally needed index - every time a particular query is run it sends the server to its knees. It's run a lot
View Replies !
Speed Of InnoDB DELETEs On Large Tables
I am finding delete queries on large InnoDB tables very slow - are there ways to speed this up? I have a table with about 100 million rows: I am trying to delete just a few of these rows (the following select takes a couple of seconds): [color=blue] > SELECT count(*)[/color] -> FROM UserSnap -> WHERE LogDate<now() - INTERVAL 750 DAY; +----------+ | count(*) | +----------+ | 308969 | +----------+ [color=blue] > DELETE FROM UserSnap WHERE LogDate<now() - INTERVAL 750 DAY;[/color] That delete query takes hours to run. The structure of the table is: [color=blue] > desc UserSnap;[/color] +----------+-------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------------------+-------+ | LogDate | datetime | | PRI | 0000-00-00 00:00:00 | | | Period | tinyint(4) | | PRI | 0 | | | UserName | varchar(50) | | PRI | | | | RateType | varchar(50) | | PRI | default | | | Rate | float | YES | | NULL | | +----------+-------------+------+-----+---------------------+-------+ Any suggestions on why this is slow, and what to do about it?
View Replies !
Loading Large Tables From Files (wikipedia)
I'm an Oracle DBA and new to MySQL. I was trying to load a 5.6 GB xml file onto mysql database using mediawiki tools. The performance decreased gradually and crashed at ~60% completion. Now I'm planning to use xml2sql tools to convert the dumps to txt format. Then I'm planning to load this using mysqlimport. I would like to run this load faster, and on Oracle, I would use the IMP parameters such as INDEXES=n and so on. What are the recommended steps when using mysql? Should I target any of the system variables? I have a 4G ram on the server and can use all of it for the load. Any pointers?
View Replies !
Time Out Message When Query Large Tables
I'm trying to get data from 6 large tables but the volume of data in each table is too large and even select * from one of them make the system stop. I have afew questions: 1-what can I do to avoid the system stop or time out message? 2- To use several tabels infomation should I use 'View' command or can I use other methods? 3-I need to create a new table and insert the result from query in it. If I use the "view" can I insert the result of the view in a table? (I use postgresql).
View Replies !
Selecting From Multiple Large Tables Quickly
My skills with MySQL typically end at "SELECT * FROM table WHERE stuff", so I've had a lot of trouble with optimizing this query. I've tried doing multiple select statements for this, but that usually comes out with an average execution time of 99s. This method has a execution time of 6s still, so I'd like to get it down. I have 4 important tables here (I'm only posting the columns which I use): `auth` UID mediumint(8) unsigned PRI NULL auto_increment username varchar(32) MUL clan_id mediumint(8) unsigned MUL 0 clan_abbrev varchar(7) MUL `clans` ID mediumint(8) unsigned PRI NULL auto_increment Abbrev varchar(7) MUL Name varchar(64) icon_id smallint(5) unsigned 0 `stats` UID int(10) unsigned PRI 0 kills mediumint(9) NULL `usernames` UID int(10) unsigned 0 ID int(10) unsigned PRI NULL auto_increment Name varchar(32) Uses mediumint(9) 0 `auth`, `stats`, and `usernames` are linked by `UID`. `clans` is linked to a row in `auth` based on it's `clan_id`. I need to search the `usernames` table for a `Name` which matches a certain text (I use "storm" in my example below). I need to return a result with matches to that search, with each row containing:The `UID` which links the tables together for that user.The matching `Name` from `usernames`The matching `username` from `auth`The `Uses` from `usernames`.The `clan_id` from `auth`.The `Abbrev` from `clans`.The `Name` from `clans`.The `icon_id` from `clans`.The `kills` from `stats`. The result should be ordered by `Uses` (from `usernames`) -- highest to lowest. The tricky part is that some users may have Ɔ' as their `clan_id` in the `auth` table, in which case the clan id, abbrev, name, and icon_id should all be blank (0 or '' based on the type). Here's what I managed to hammer out with my limited knowledge of SQL: ( SELECT usernames.UID AS `UID` , usernames.Name AS `result` , auth.username AS `playername` , usernames.Uses AS `Uses` , auth.clan_id AS `clan_id` , clans.Abbrev AS `clan_abbrev` , clans.Name AS `clan_name` , clans.icon_id AS `clan_icon` , stats.kills AS `kills` FROM `usernames` , `auth` , `clans` , `stats` WHERE usernames.Name LIKE '%storm%' AND auth.UID = usernames.UID AND clans.ID = auth.clan_id AND stats.UID = auth.UID ) UNION ( SELECT usernames.UID AS `UID` , usernames.Name AS `result` , auth.username AS `playername` , usernames.Uses AS `Uses` , 0 AS `clan_id` , '' AS `clan_abbrev` , '' AS `clan_name` , 0 AS `clan_icon` , stats.kills AS `kills` FROM `usernames` , `auth` , `stats` WHERE usernames.Name LIKE '%storm%' AND auth.UID = usernames.UID AND auth.clan_id =0 AND stats.UID = auth.UID ) ORDER BY `Uses` DESC It works great, but the average query takes around 6s (these tables have several thousand entries in each).
View Replies !
MySQL MYISAM Multimaster Replication And Backup
I was wondering if anyone could point me in the right direction on backing up a Multimaster replicated system. I have two redhat linux machines with MySQL 5.0.24 max with a working multimaster database that will eventually grow to around 50Gig (2Gig at present). I need an automated fast way to backup this setup. at present I am manually doing the following (not sure if it is the right thing to do): 1. flush tables with read lock; 2. shell> tar zcf xxxx.tar.gz /datadirectory 3. show master status; (record repl cordinates) 4. unlock tables;
View Replies !
Myisam Table Gets Corrupted, Clogs Mysql, And Brings Server Down
I have a few (I think) larger MyISAM tables like 200 000 - 300 000 thousand rows. Sometimes for some reason one of them gets corrupted, and all the following queries sent to it start to hang and clog up the mysql server, and in the end it brings down my entire server including apache. I am a little desperate here for a solution. Would turning on auto repair help? Whenever such a thing happens, I quickly shut down the server and send a repair to all tables involved, but surely I cannot sit there all day long :)
View Replies !
MySQL With Large Table.
I am using MySQL for a table which will have 100M+ records, avg length of records being 130 bytes. When the number of records reach approx. 25M (and the file size close to 4GB), the rate of inserts falls drastically from 800 per second to 30-40 per second. Details: * MySQL 3.23.58 on Fedora Core 3 * Table has 4 indices. * I have got rid of 4GB file size problem with MAX_ROWS=1000000000. * File system : ext3 on single disk. ext3 could create 10G file without much trouble. So I am convinced that ext3 is not the bottleneck. * Tried using InnoDB engine but it also doesn't meet the requirements. Requirements of database: * A single table in the database with 100M+ rows, each of size 130 bytes (approx). * 500-600 inserts per second. * 200 selects and 200 updates per second. (These statements will affect only one row) * 3-5 select statements per minute which can return 10k to 500k records. * No foreign keys/ACID transaction requirements. * Fast recovery in case of crash. Questions: * Does MySQL performance drops when the table grows beyond 4G? * Which are most important server variables which need to fine tuned? Currently I am using only key_buffer = 512M.
View Replies !
Large MySQL Database
There are many threads on here about large db designs etc but I'm looking for a little information I have been unable to find anywhere. What sort of design to places like facebook/myspace use for their database(s). Is it best to have a table for user info (id, username, email, etc) then have a table for every feature of your site (blogs, pictures, friends, comments etc etc) or do they have a table for every user. I would assume the first as a table for every user would soon grow very very large and become inefficeint.
View Replies !
Large Database In Mysql
I have a database with two tables in MySQL 4.1. Die one tabel contains about 300,000 records and the other table contains about 70,000 records. I tried joining and subquering (very simple sintax) these two tables and received no result. The processor of the server was being tied down. I went to a bigger computer with the same results. I then tried minimizing the tables and had to go to about 10000 and 8000 records respectively, before it worked. I did not try indexes, because I wanted to make a comparison between no indexes and with indexes. Granted I did not tweak many server variables, but shouldn't this just make the query slower and not completely tie it up?
View Replies !
Importing A Large Db To Mysql
I have a DB creation script of size about 50MB. I cannot seem to load it to the mysql db I have installed at home (I have a P3 , 512MB RAM), as my computer runs out of memory. Is there a way to force mysql (ver 5.0) to flush the memory from time to time to the HD? Is there a way to break the script to several small sub-scripts?
View Replies !
|