UPDATE Function Very Slow??
I have a large table (77,321 Rows) and I'm trying to update it. For some reason, UPDATE takes a long time. Maybe it's my query? I'm doing it through php, maybe that's it? I'm running the program locally using the CLI, and it still takes ages.
Should I not expect it to be as fast as SELECT functions?
$update ="UPDATE `ch_products` SET `products_weight` = '".$IDS[$i][Weight]."' WHERE `xref1` = '".$IDS[$i][ID]."'";
How can I make this faster?
View Complete Forum Thread with Replies
See Related Forum Messages: (Click on the Icon for short description)
Update Too Slow

I need to update 25 * 5000 records, if I do one at the time it takes too long time, do any one have a good proposal ?
Slow UPDATE

I have a table with the following structure;
CREATE TABLE my_table ( id_1 int(11) NOT NULL , id_2 int(10) NOT NULL , stauts tinyint(1) NOT NULL DEFAULT 0 , PRIMARY KEY (id_1) ) Engine =InnoDB';
The table currently has arround 100,000 entries. When I try to run variations of the following statement it is taking around 4 seconds per query;
UPDATE IGNORE my_table SET id_1 = 74240, id_2 = 5
I need it to be running a lot faster than 4 seconds per query as I need to update upwards of 100,000 records a day! My server is fairly beefy, a 3 gig dual core opeteron and is generaly running below 1.0 load.
Slow Update Query

I have about 2000 update queries to do, which takes about 1 hr on 250,000 rows. My table is getting kinda slow here is the query i am using UPDATE nametable SET sectionname = replace(sectionname,'".$oldsec."','".$sec."'), categoryname = replace(categoryname,'".$oldcat."','".$cat."'), published=Ƈ' where sectionname='".$oldsec."' and categoryname='".$oldcat."' ;
I am wondering if the same thing is possible with an insert... on duplicate key statement?
I cant seem to get the insert statement to work, but not even sure whether it is appropriate.
With this query I am basically finding and replacing some columns based upon another table (within the php script I am using)
Very Slow Update Statement

I am having an issue with an UPDATE statement that takes a very long time. I am using 1 table in a schema to update another table in another schema. Below are the create statements and the update statment I am using. Table and column names have been changed to protect the innocent :) Code:
Very Slow Table Update

I have two tables. One is really a subset of the other. However, they came in different data files and I would like to pull data from one and put it into the other. However, it is VERY slow!
Once the tables are setup I will only read from them and perform operations. I will never update or insert. However, I can't get things setup to that point. Code:
IF Function,GROUP BY,aggregate Function Problems

Yep, I have all those problems in the title. So I'll explain each one at a time - I did have another thread relating to this very same query but I thought it was time to update where I am with the query because at the moment I feel like I am getting nowhere!
The query I have basically searches through an items_ordered table through each product and checks to see whether the item is VATable or not. This is not where I have the problem though. Where I am really having the first problem is when I am trying to use the IF function to check if the TOTAL of an order is over £300. IF it is then I multiply it my 0.95 (i.e. 5% off). With the query below I get no errors but neither do I get the desired result. It's as though it couldn't even see it. =....
Slow

What generally would be the reason why all my db driven sites are running slowly or even hanging. I am on braodband speed but just changed hosts.
Slow Query

i have this query on a website/webapp that has expanded beyond all expectation. It now takes nearly 30secs to return results from the database SELECT cl_t.Client_ID, Buyer_1_Title, Buyer_1_Prename, Buyer_1_Surname, Tel_No, Mob_No, Buyer_2_Title, Buyer_2_Prename, Buyer_2_Surname, Email_Add, Price_Max, MAX(activity_t.Date) AS lastcomm FROM cl_t INNER JOIN cl_want_t ON cl_t.Client_ID = cl_want_t.Client_ID AND Agency_Code ='$agencyloggedincode' AND Deleted = 'N' LEFT JOIN activity_t ON Buy_Sell = 'B' AND Ref_No = cl_t.Client_ID WHERE cl_t.Sales_Agent_ID = $agentid GROUP BY cl_t.Client_ID ORDER BY $order The problem is the call to MAX(activity_t.Date) AS lastcomm activity_t holds all known contact with all known clients and as such is a very large table, the call to search through all of these records and return only the date of the last entry for this client is taking the time. If I remove this from the query I get results in 3 seconds. I have indexing on activity_t.Date & activity_t.Ref_No Question, is there a way of doing this quicker within the table I already have, or should I create another table that just holds the last update date for each client, and get the date from this much smaller table.
Slow Authentication

MySQL V 5.0.18 on SUSE 10.1
I'm not a complete *nix noob, but I sure as hell ain't a *nix or MySQL pro.
This is a new installation. Everything screaming fast. Unless it deals w/authentication.
Try to get in w/SQLyog from W2K locally ... intitial connection takes ~20 seconds. Then everything screaming fast.
Web Server (W03) attempts to connect via MyODBC ... same result ... initial connection takes ~20 seconds. Subsequent queries screaming fast.
VNC into the box at any time ... everything fast. (would seem to eliminate network/connection issues)
Why Is This Query Too Slow?

I find this query to be exceptionally slow(around 2.5 seconds), could some tell me why this is so?
MySQL SELECT st.profile_views,count( DISTINCT p.ID ) news_submitted, count( DISTINCT pv.ID ) news_voted, count( DISTINCT pcom.ID ) news_commented, u.joined, u.weight FROM users u LEFT JOIN posts p ON p.submitted_user_id = u.user_id LEFT JOIN post_votes pv ON pv.user_id = u.user_id LEFT JOIN post_comments pcom ON pcom.user_id = u.user_id LEFT JOIN stats st ON st.user_id=u.user_id WHERE u.user_id='john' GROUP BY u.user_id I traced the cause to this line count( DISTINCT p.ID ) news_submitted (from LEFT JOIN posts p ON p.submitted_user_id=u.user_id) But when i execute something like this
MySQL SELECT count( DISTINCT p.ID ) news_submitted FROM posts WHERE submitted_user_id='john' it is quite fast (around 0.03 seconds) So why does it slow down when i'm joining the above query with 3 other tables ? Should i use INTEGER for user_id instead of string like 'john'?
Slow Query Log

my slow log is catching a slow query, however the timestamp for the query is "0". I also placed a timestamp on the query to echo out to the results page, and it is about 4 thousands of a second. Why is it showing in the slow log?
Slow Subselect

I've got two tables: lo_users: nickname|id|... lo_friends: from|to|...
The following query takes < 0.01 sec: SELECT IF(`from` = '10855', `to`, `from`) userid FROM lo_friends WHERE (`from` = '10855' OR `to` = '10855') AND STATUS = '1'
...but if I use it in a subselect, the whole thing takes about 0.54 sec: SELECT u.nickname FROM (SELECT IF(`from` = '10855', `to`, `from`) userid FROM lo_friends WHERE (`from` = '10855' OR `to` = '10855') AND STATUS = '1') f LEFT JOIN lo_users u ON u.id = f.userid
What can I do to make the query faster? "from" and "to" are indexed and lo_users.id is the primary key.
Slow Query Using NOT IN

I am migrating a MSSQL server to MySQL. I know the following SQL is valid for both servers, but MSSQL finishes execution of the query almost instantly, and MySQL has been running the query for the past ten minutes and still is not finished. There is basically the same amount of data in each database. Does anyone know ....
MySQL Slow

I had downloaded a few years back mySQL v3.51 installed but never used it. Now I wanted to convert some B-TREE databases to mySQL and did some testing via ODBC to insert 70,000 records: My results:
MS ACCESS: ~60,000 msecs MYSQL v3.51 ~18,000 msecs
Impressed with the speed, I went ahead and got the latest MySQL v5.1. Uninstalled the older version, I had nothing there to preserve, so I did a simple new install with MySQL v5.1. I noticed the size of the files and BINEXE increasted by 1,000,000%. Ok, Bulky. Not a problem.
I reran the same ODBC test, and now I got:
MYSQL v5.1: ~450,000 msecs or 7.5 freaking MINUTES!
What the hell happen? Nothing was done. I'm knew to MYSQL. I just installed it with all the defaults. I did choose "developer's machine" for the "optimizer wizard"
I can't redistribute MYSQL v3.51 and force it down people's throats! I have to use what they are using already, if already installed. Not even my current system takes 1 minute to add 70,000 records. Why 7.5 minutes? All it is simple inserts/free statements.
Join Too Slow

I'm creating a query that use Join clause. I tested it in MySQL 4.0.24 and with MS-ACCESS. . . . in MySQL is slow!!! any suggestion ?
Slow Connection

I build an application and installed it on many machines. In every machine except two, the program works without problems. On this two, the connection with database is too slow.
I saw the opened doors with 'netstat' and the computer opens about 5 or 6 ports (to the port 3306 of the mysql server) before sucessfuly connect with MySql Database and execute the sql. I don't know what could be happening. I realy need to fix this because the progrm is too slow with this error. Could anyone know what could be happening??
Slow Connect

Does anybody know why it sometimes takes more than 10 seconds to connect to a database and sometimes it just takes half a millisecond?
Slow Queries

I had a working web page that queried 20 tables and returned the data in the form of a table ... all of a sudden this stopped returning the results , and on investigation, up to ten tables, the query time is about 0.01 second ... but as the number of tables is increased to fifteen, the query time increases to 60 second .. and then gets too slow with nothing being returned at all.
A few days ago, this was all working fine. There have been no changes to the code on the web page .... The version of mysql is 4.0.20, the server is a dual 1 MHz Xeon with 512 meg of RAM, running linux.
The tables have up to 15 fields each, and there is only simple text or numerical values in the fields.
Can anyone suggest what might have changed to suddenly slow down the query ?
MySQL Very Slow.

I have this one site that slows down all my others because the queries are so massive.
For example one of these queries I use to-do a search by a user's account number. I also get the position he is at on the list, and in order to-do that I need to select ALL the rows.
For example, I filter out the other queries in php. CODE$num = 1; $q = mysql_query('SELECT * FROM lists'); while($r = mysql_fetch_assoc($q)) {
if($r['account']=='accountNum') { print 'You are at pos. num '.$num.'<br>'; } $num++; }
Why Does MySQL So Slow

I just changed to use MySQL few days ago but it was a bad idea. My server now is running very slowly with the database. I'm using Perl5 and DBD::Mysql in my script. The system is Linux9, Apache2.
I looked at these mysql pid and saw a lot of activities (about 400) while there are more 100 users online at this moment and lots of running under a the same pid number.
What Causes Slow Queries

What causes periodic slow queries? I have checked my slow query logs and for some reason everyonce in awhile, a query thats never slow might be for example, one took 3 seconds to execute and every once in awhile a chat might take 10 seconds of cpu time while rest of the time 0.09...why is it it flexuates so much?
Very Slow Select

The line indicated below from my php script is very slow (about 10 seconds). I have this field indexed so I thought that it would be much faster. Could someone tell me what might be wrong?
I'm also including the dump of the table definitions. This is a cd cataloging database.
Right now the filenames table is empty and I'm trying to populate it, but at the rate it's going it would take days. I have about 700,000 records in the 'files' table, but none in the 'filenames' table yet. Code:
Slow Running Sql

i am not using mysql but an unknown database system on a unix box - i have no control over the database but have purchased an odbc driver that seems very 'clunky' after using mysql - this is an sql statement question rather than a mysql tech question. if i run this:
SELECT MK_01_vehicleRecords.registrationnumber, MK_01_VehicleRecords.vehiclenumber FROM MK_01_VehicleRecords WHERE (MK_01_VehicleRecords.vehiclenumber = '36176')
Complex Query - UPDATE Within UPDATE?

Edit: Before anyone leaves this thread, don't be put off by the regular expressions! They are not the problem, so please stay and read.
OK, this query has got my head spinning. I am basically creating a query that goes through each product in a table to update the stock for that particular item with that particular size (i.e. I am talking about shoes - different models and each model has different sizes (uk kids 12 -> uk 11).
With each shoe it does (or is meant to do) the following: 1. The PHP script that runs the query is looping through every size outside of the query 2. So for each of these sizes it checks to see whether the product it is currently on matches the size it is on 3. When it finds the size it is on, it then deducts the correct number of units from the stock table 4. The final WHERE clause makes sure this subquery inside the UPDATE only happens when the StockUpdated field of the Product table equals 0 (in other words, the stock hasn't been counted before)
Basically what I need to do, is first to make sure what I currently have got does the above correctly but also I need the query to UPDATE the StockUpdated field to 1 only when it has been updated successfully. How could I do this? Unfortunately I cannot just add an extra update entry to the end of the query as this would update the StockUpdated field regardless of whether it has been properly counted or not.
Here is the query I have so far (with a little simple PHP around it doing the loop):
PHP
$shoesizes = array(1 => 'ukk12','ukk13','uk1','uk2','uk3','uk4','uk5','uk6','uk7','uk8','uk9','uk10','uk11'); $numshoesizes = count($shoesizes); for($i = 1; $i < $numshoesizes; $i++) { $stockupdate = " UPDATE heelys_stock,items_ordered SET heelys_stock.size_".$shoesizes[$i]." = (SELECT CASE WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?( )?(Kids)?( )?( )?(UK)?( )?( )?(Kids)?( )?( )?[^0-9]12( )?(' -- if UK Kids 12 THEN heelys_stock.size_ukk12 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?( )?(Kids)?( )?( )?(UK)?( )?( )?(Kids)?( )?( )?[^0-9]13( )?(' -- if UK Kids 13 THEN heelys_stock.size_ukk13 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]1( )?(' -- if UK 1 THEN heelys_stock.size_uk1 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]2( )?(' -- if UK 2 THEN heelys_stock.size_uk2 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]3( )?(' -- if UK 3 THEN heelys_stock.size_uk3 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]4( )?(' -- if UK 4 THEN heelys_stock.size_uk4 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]5( )?(' -- if UK 5 THEN heelys_stock.size_uk5 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]6( )?(' -- if UK 6 THEN heelys_stock.size_uk6 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]7( )?(' -- if UK 7 THEN heelys_stock.size_uk7 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]8( )?(' -- if UK 8 THEN heelys_stock.size_uk8 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]9( )?(' -- if UK 9 THEN heelys_stock.size_uk9 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]10( )?(' -- if UK 10 THEN heelys_stock.size_uk10 - (items_ordered.Amount/items_ordered.Price) WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]11( )?(' -- if UK 11 THEN heelys_stock.size_uk11 - (items_ordered.Amount/items_ordered.Price) FROM items_ordered WHERE items_ordered.StockUpdated = 0) WHERE (heelys_stock.id = (SELECT heelys_stock.id FROM heelys_stock,heelys_shoe WHERE SUBSTRING_INDEX(items_ordered.Product,',',1) = heelys_shoe.full_shoe_name)) , items_ordered.StockUpdated = 1" // at the moment this last update of the items_ordered table happens to every record!!! even if the other part of query fails
// update stock for size $i mysql_query($stockupdate); }
Hope someone can see how I can do this? I've been working on this query for 2 or 3 hours now and I've been making reasonable progress but now I am really stumped.
Update Replication, Force Update

Recently an error in the db on my master caused the slave to fail. I noticed this after a few days when I looked at the status and it said "Slave_SQL_Running: No". After looking further I saw what the error was on the master.
What is the best method of re-synching the databases?
Is there a command to force a re-replication or synch of the dbs? Would you delete the slave's db and update over? In this case, is there a command to pull the data down from the master?
Unable To Update - Have Update Priveledge

I've been granded update priveledge to tables in a few databases on our server:
Select_priv ,Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, and Lock_tables_priv are all set to 'Y' for a selected database.
I can connnect and read the data and data definitions just fine. I cannot insert, update, delete, create, or alter any table in this database.
Our admin worked for a couple of hours yesterday trying to resolve the issue, but no joy. I've googled for this problem and the most relavent posts I've found were problems related with users not being able to connect. I can connect and I can read, I just can't do any of the other priviledges.
Order By Super Slow

I have a text field that's indexed. When I try to sort this column (alphabetical), the first page is pretty fast. However, getting to the end, it slows down a lot, taking about 7 seconds just to show the last page of results. Is there any way to speed up the sorting?
Slow Left Join

I've never come across this before, a very straight ahead query running extremely slowly... Table1 Id | Field1 | Field2 Table2 Id | Table1Id | Field1 | Field2 Query.... SQL SELECT Table1. * FROM Table1 LEFT JOIN Table2 ON Table2.Table1Id = Table1.IdWHERE Table2.Table1Id IS NULL NOTE: An existing record in Table2.Table1Id is never null, it will always have a record of some description. We're just looking for missing records in Table2. This query is taking anywhere from 6-20 seconds to run. It's really got me baffled as I thought it should run extremely quickly. There's about 10,000 records in each table and the query appears to be producing the correct result, just extremely slowly.
Slow Query Log Files

I have edited my.ini file to create a file called slow queries. My problem is that when the server starts up i do not get a full list of all slow queries. Is there anything else i need to change? How else can i come about in getting all queries that took a long time to execute? im using mySQL 5.0.9.
Slow Query Log Not Staying On

I'm running MySQL 4.0.16 on Windows 2003. I just added the mysqld-nt command line option to enable the slow query log, started MySQL, and the option showed up as turned on. Then later I restarted the server, and the slow query log option went back to being turned off. Is this a Windows problem in not remembering the service parameter? Has anyone else seen this?
Slow Response From MySQL

I was wondering if any one can help me out, I am literally tearing my hair out with an availability search I have written.
Previously I was selecting all the records from two databases but noticed the response time was very slow anything up to 20 secs.
I tried to streamline the search by only selecting the columns I needed from the tables and created indexes for each of the tables for the required rows but now the results are executing in around 50 - 60 secs, which is ultimately alot slower.
The SQL query I am using at the moment is this:
SELECT villas.id, villas.resort, villas.beds, villas.owner, villas.air_con, villas.walk_beach, villas.walk_shop, pricing.id, pricing.week, pricing.price, pricing.availability FROM villas LEFT OUTER JOIN pricing ON villas.id = pricing.id WHERE pricing.week = 1073088000 AND pricing.availability = 1 AND villas.beds > 0 AND pricing.price > 0 AND ( villas.resort = 'cala_dor' OR villas.resort = 'pollenca' ) GROUP BY villas.id ORDER BY villas.owner DESC , villas.beds ASC
Slow Response From MySQL

I was wondering if any one can help me out, I am literally tearing my hair out with an availability search I have written.
Previously I was selecting all the records from two databases but noticed the response time was very slow anything up to 20 secs.
I tried to streamline the search by only selecting the columns I needed from the tables and created indexes for each of the tables for the required rows but now the results are executing in around 50 - 60 secs, which is ultimately alot slower.
The SQL query I am using at the moment is this:
SELECT villas.id, villas.resort, villas.beds, villas.owner, villas.air_con, villas.walk_beach, villas.walk_shop, pricing.id, pricing.week, pricing.price, pricing.availability FROM villas LEFT OUTER JOIN pricing ON villas.id = pricing.id WHERE pricing.week = 1073088000 AND pricing.availability = 1 AND villas.beds > 0 AND pricing.price > 0 AND ( villas.resort = 'cala_dor' OR villas.resort = 'pollenca' ) GROUP BY villas.id ORDER BY villas.owner DESC , villas.beds ASC
Does Too Many Tables Slow Down Websites

Just wondering if having too many tables in one database slows down a website and would it be better to have seperate databases rather than one big one?
Slow Left Join

Well I'm trying to do a left join on a couple tables "USERS" and "EVENT_LOG", event_log has a considerable number of rows (1.7mil). I'm trying to do a query to find out which USERS have no entries in the EVENT_LOG of a specific EVENT_TYPE.
Here's the query I'm attempting:
select USERS.USER_USERNAME, 0 as eventCount from USERS left join event_log on USERS.USER_ID=event_log.USER_ID and EVENT_TYPE='AUTHENTICATION' where event_log.USER_ID is null and USERS.CUSTOMER_ID=33700077 group by USERS.USER_ID
EXPLAIN output: SIMPLE USERS ref CUSTOMER_ID CUSTOMER_ID 4 const 155 Using where; Using temporary; Using filesort SIMPLE event_log ref USER_ID USER_ID 32 const 12139 Using where; Using index; Not exists
This takes 1.5sec, which is quite long considering the right join takes 31ms which is doing alot more (i.e. counting).
Right Join:
select USERS.USER_USERNAME, count(event_type) as eventCount from USERS right join event_log on USERS.USER_ID=event_log.USER_ID and EVENT_TYPE='AUTHENTICATION' where USERS.CUSTOMER_ID=33700077 group by USERS.USER_ID
I have indexes on USER_ID in the USERS table, and USER_ID/EVENT_TYPE ("USER_ID" index) in the EVENT_LOG table.
So anyone have an idea as to why this is so slow? Shouldn't it be querying the "USER_ID" index in the EVENT_LOG table and simply requesting the event type "AUTHENTICATION" and adding it to the resultset if it comes back null?
MS ACCESS Frontend SLOW

Having fought my way through getting ODBC running with Access and MySql, I now find its like watching paint dry when I go to look at a table with Access, including scrolling down/doing a query. Is this the best I will get??? or have I missed something.
MySQL Slow In Windows NT4

I am running the Apache web server, MySQL v4, and PHP on an NT4 server. Apache runs great, but the auction software I am using (Web2035 Auction software written in PHP) is very, very slow.
Sometimes it takes 20-30 seconds to bring up an auction page from the items table which has less than 200 records in it.
Can anyone can give me some pointers on where to start looking? (I don't know if the bottleneck is with MySQL or PHP or what I might need to look at to enhance the performance of either package.)
MySQL Is Slow, Trying To Optimize

It just seems that my system is slow, adding records, etc. I tried to optimize it, saw that there was a my-medium.ini file, read that is was for medium sized system. I replaced it with my.ini (yes I did make a backup, thankfully) and restarted mysql.
Pretty much it hangs. I tried to connect with QueryBrower, did a Select Count(*) and just froze. I admit that I didn't wait for ever, yes I know I Select Count(*) takes a long time but I gave up after waiting 3x as long as I normal did. Also the logs screen froze in administrator.
Slow Write Speeds

Here is what i have
IBM x226 - 8GB ram - 2x 3.4 Ghz Xeon (single core) processors - RAID 5E (6x300GB disks)
Suse Linux 9.0; MySQL 5.0.13
So, I am migrating from SQL server 2000 on a much smaller Dell PowerEdge (2gb ram, 2 Xeon 3.0 Ghz, Raid 5 over 5x74GB). I am exeriencing very slow write times.
For instance, there is one table on both servers that has approx 9mil rows...here is a basic test:
Update loan set test_col = 1;
Platform Time IBM/Linux/MySQL 5 9:45 Dell/Win/SQL server 1:37
The tests were run during very light server activity and I tried them multiple times.
Our IT department is fairly insistant that the IBM server is running per spec...obviously something is not right. I have changed some of the server variables with no improvement.
Extreamly Slow Search?

I have the following 2 tables
table pictureinarticle{ 'id' int(10) unsigned NOT NULL auto_increment, 'articleid' int(10) unsigned NOT NULL, 'pictureid' int(10) unsigned NOT NULL, PRIMARY KEY ('id'), KEY 'pictureid' ('picutreid', 'articleid') }
table article{ 'id' int(10) unsigned NOT NULL auto_increment, 'timestamp' timestamp(14) NOT NULL, PRIMARY KEY ('id'), KEY 'timestamp' ('timestamp') }
'articleid' in table 'pictureinarticle' is PRIMARY KEY 'id' in 'article'.
Now, I want to search total number of pictures in all articles that are in a time range START and END (both of TIMESTAMP type). It is a simple search as follows:
select count(pictureid) from pictureinarticle where articleid in ( select id from article where timestamp between START and END);
PROBLEM: - the above search took about 110 seconds to finish.
Data: - Number of articles in [START, END] is around 260,000, returned from 'select id from article where timestamp between START and END'.
- Number of records in table 'pictureinarticle' is around 1,400,000.
Analysis: - select articles in [START, END] is fast, no more than 1 second: select id from article where timestamp between START and END.
-it is 'select count(a.pictureid) from pictureinarticle a, article b where a.articleid in (...)' that actually cost 110 seconds.
This seems to be due to a poor indexed table? But I did have 'articleid' indexed in table 'pictureinarticle'.
So, what may cause this slow search problem? Will it help if we index on 'articleid' before 'pictureid' in table 'pictureinarticle'?
Enabling -- Log - Slow - Queries

I want to enable --log-slow-queries of MySQL.
How do I do it without restarting the DB server?
MySQL Slow Starting Up

I am using a Windows 2003 Web Edition Server running IIS and MySQL 4.1. I had to restart the server the other day and it took MySQL almost 2 hours to come back up. I was watching it on my task manager and it went up to approximately 60,000k in 10k increments before I was able to access MySQL.
My CPU usage was hovering around 3% all this time. Everything else came up on the server just fine. This happens every time I have to restart my server. The reason I have to restart my server most of the time, is because MySQL locks up on me.
Is there any settings I can change that would help me here? Any help would be greatly appreciated.
One more thing to add. I am using the default my.ini file. We have almost 100 different databases on the server and have around 20000 tables within all of these databases combined. All of these tables are InnoDB tables.
Slow Performance Using MyODBC

I am creating a pair of applications that essentially transfer data from a remote client to a local server. The trick is that "remote" in this application means "way out in the mountains where it takes an hour by four wheel drive to reach the nearest paved road and don't even talk to me about a cell tower for another hour or so of driving".
Because of this, we are using shoe-leather-net to communicate between the client and the server. The client is collecting data into a MySQL table. Every so often, a person will use the client application to copy the data onto a thumb drive and carry it down the mountain to the server, where the partner application will copy the data into an identical MySQL table. These are distinctly non-technical people I am talking about here - typing a file name is a high-skill activity - so this needs to be a dead-simple user interface.
The data is sensitive, so it is encrypted going on to the thumb drive and decrypted coming off.
Here is the question: The copy process that I have programmed is very slow - on average 2 seconds per row - on both ends of the transaction and this does not seem right. What can I do to improve it?
When the process is running, Task Manager shows that mysqld-nt is using as much of the CPU as it can get and the actual application is only using CPU time once in a while.
The basic client task is this: -- Read a row from the local table -- Encrypt the row -- Write the encrypted row to the file -- Repeat until all of the unexported data has been copied
The basic server task is the inverse: -- Read a line from the file -- Decrypt the line and construct a corresponding INSERT statement -- Execute the INSERT -- Repeat until end-of-file
Other possibly pertinent information: -- Windows XP Pro -- Visual Basic.Net -- MySQL 4.1.14-nt -- MyODBC 3.51.13 Dave Gee
MySQL Running Very Slow

I have the following INSERT SQL, which runs very slow (For 2 full days it had not done anything) on a 2 processor Compaq machine running Suse Linux. Code:
Slow Running MySQL?

I'm hoping someone may have an idea what could be causing the slow loading pages of my web-site. I'm not positive, but I'm relatively sure that it's related to a problem with MySQL database.
I purchased a program called Sam3 for broadcasting our radio signal over the internet. The software requires the use of MySql in order to set up web pages for our web site.
The problem is, that while everything works GREAT (requests can be made from the site, songs can be searched, the history of what we've played shows up) the pages load PAINFULLY slow. Other users of this software have had no such problems so I'm at a loss.
I know from testing that the PHP script for the web pages is fine, I have plenty of bandwith both upload and download available on my DSL line, and while the computer running MySQL is behind a router I have tried plugging the DSL line DIRECTLY into the host computer and it makes no difference.
For all appearances it seems the problem is that it takes MySQL forever to gather and provide the information needed for these pages. Does anyone have any idea what I should be looking at to solve this problem?
I do not know the MySQL program at all, so I get somewhat lost when people start throwing out technical terms, but this has been really frustrating because no one else seems to have the problem and everyone so far has just told me to check the things I've already checked.
Query With 3.3million Rows Is Slow?

I'm not that great with MySQL...so I was hoping someone could help me out. The query I'm running is too slow...can anyone tell me what I can do to speed it up..if I can at all? I was wondering if because ZipListMatrix has 3.3 million rows that 8 seconds is all the faster it's going to be. Any help is greatly appreciated! I have already "optimized" the tables.
Can't Turn On Slow Query Logging

long_query_time = 1 log-slow-queries = /var/lib/mysql/slow_queries.log Is the above syntax not correct for enabling slow query logging? All examples I've seen have the dashes in the second variable and underscores in the first.
When I restart MySQL with those lines in my.cnf, it fails to start, but writes nothing to its error log. /var/lib/mysql/slow_queries.log exists, is owned by mysql, and has read/write permission.
Turning On Slow Query Logging?

Background: I paid a young admin set me up on a database server. He installed the basic I needed for the server...at my request...No Cpanel...mysql and apache and some tight security w/o even a domain name to SSH into. Unfortunately, he's a busy kid, and teens sometimes don't realize that people depend on them...and well, I can't really seem to get him to do much so I gave up and figured it's a good way to force me to learn all this myself... Well anyway, now I want to turn on Slow Query logging. But before I do that, I need to know how MySQL is running. Is SQLogging turned on already? Where is it logging to? So first thing I want to look up is, when the server is rebooted, what's the command to restart mysql? No clue. How do I change the setting? And of course, the server is production, so when I make the change, it needs to be quick, it needs to be smooth, and I need to be able to roll back to the previous config if necessary. I'm running Redhat Enterprise.
Help Rewriting A Slow Phpbb Query

I have a "glance" or "Recent Topics" list on my forums that have become fairly complex. I modified an already feature rich glance mod to allow users to select individual forums to exclude from showing topics in the list. As well when users are members of certain forum groups, they see topics from the group forum in the list, and they are highlighted a different colour.
The main SQL query to create the list often is showing up in the MySQL Slow_query log and I'm pretty sure is the main cause for the page loading slow.
I am no mysql Guru, so I thought I would seek the advice of some to improve or totaly rewrite this slow query.
PHP
$sql = "SELECT f.forum_id, f.forum_name, t.topic_title, t.topic_id, t.topic_last_post_id, t.topic_poster, t.topic_views, t.topic_replies, t.topic_type, p2.post_time, p2.poster_id, u.username as last_username, u2.username as author_username FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u, " . USERS_TABLE . " u2 WHERE f.forum_id NOT IN (" . $forumsignore . $glance_recent_ignore . ") AND t.forum_id = f.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND t.topic_moved_id = 0 AND p2.poster_id = u.user_id AND t.topic_poster = u2.user_id ORDER BY t.topic_last_post_id DESC"; $sql .= ($glance_recent_offset) ? " LIMIT " . $glance_recent_offset . ", " . $glance_num_recent : " LIMIT " . $glance_num_recent;
The "NOT IN" list varies per user, but here is an example: NOT IN (77,75,76,25,26,37,63,64,66,67,67,1,25,26,37,70,28,75,76,78)
Remote MySQL Connection Slow

I have a website on a dedicated server that was running really slow, so I got another, much faster server and transferred the MySQL database to this server. However, now when I connect to the faster server's database using the slower server's PHP web pages, the overall page loads much slower than when the database was on the slower server.
Any ideas why this would be? Right now the host name is just an IP address. Does it need an actual resolved hostname to be fast? MySQL on the faster server is supposedly tweaked for fast service (my-huge.cnf).
|