473,809 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Optimizing MySQL

Hi,

I wrote a php+MySQL-based reservations system for a local restaurant.
MySQL is running on AMD Athlon 3000+ 2GHz with 1.5Gb of RAM. The
system is accessed through Intranet by 4-5 machines.

The main reservations table weighs only 40k with around 150 entries,
but I'm getting weird lags in the middle of the pages - half of the
table loads ... LAG! ... then the other half loads. This is especially
annoying considering the table will contain around 3,000 - 5,000
entries per year, entries older than 2 years will be removed.

The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.

I don't use "SELECT ALL" queries, my tables are optimized, etc.

Help!

Jun 5 '06 #1
5 1415
TristaSD wrote:
Hi,

I wrote a php+MySQL-based reservations system for a local restaurant.
MySQL is running on AMD Athlon 3000+ 2GHz with 1.5Gb of RAM. The
system is accessed through Intranet by 4-5 machines.

The main reservations table weighs only 40k with around 150 entries,
but I'm getting weird lags in the middle of the pages - half of the
table loads ... LAG! ... then the other half loads. This is especially
annoying considering the table will contain around 3,000 - 5,000
entries per year, entries older than 2 years will be removed.

The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.

I don't use "SELECT ALL" queries, my tables are optimized, etc.

Help!

You might be better of posting details in a dedicated mysql group. Did
you already try the explain keyword to assure that you have correct
indexes and optimization?

http://dev.mysql.com/doc/refman/5.0/en/explain.html

Jonathan
Jun 5 '06 #2
The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.


Try adding indexes to fields in the table that you are searching on.
ALTER TABLE reservations ADD INDEX (date);

Let me know how it goes.

Jon Tjemsland

Jun 5 '06 #3
TristaSD wrote:
Hi,

I wrote a php+MySQL-based reservations system for a local restaurant.
MySQL is running on AMD Athlon 3000+ 2GHz with 1.5Gb of RAM. The
system is accessed through Intranet by 4-5 machines.

The main reservations table weighs only 40k with around 150 entries,
but I'm getting weird lags in the middle of the pages - half of the
table loads ... LAG! ... then the other half loads. This is especially
annoying considering the table will contain around 3,000 - 5,000
entries per year, entries older than 2 years will be removed.

The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.

I don't use "SELECT ALL" queries, my tables are optimized, etc.

Help!


Sounds like you're running into a serious case of lock contention.
Here's a good article on the topic:

http://www.devshed.com/c/a/MySQL/MyS...zation-part-2/

Jun 5 '06 #4

TristaSD wrote:
<snip>
The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.


What about when you remove the "%" from condition part (as in
%today%)?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 6 '06 #5
hahaha I was just implying that some VALID code goes in between % %.
:)

R. Rajesh Jeba Anbiah wrote:
TristaSD wrote:
<snip>
The lags persist on MySQL server (locally), so it's not a network
issue. The lags are espeically bad when I do a query like "SELECT
name, phone, notes FROM reservations WHERE date > %today%" - it
literally takes 5-6 seconds to pull one row.


What about when you remove the "%" from condition part (as in
%today%)?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/


Jun 6 '06 #6

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

Similar topics

0
1185
by: Jackson Miller | last post by:
I need to have a web application be able to import large amounts of data (400,000 rows of 10 columns). I know how to script it and have it running in the background. However I want to know how I can optimize my insert statements to try to speed things up. Will it help if I insert multiple rows at a time? If so, is there a magic number or range? The same would also go for updates.
0
493
by: Apollo | last post by:
1.2Ghz Pentium, with 1/2Gig of ram, 4.0.14MySQL, RedHat9.0 I have about 20K records that result from the following query. Front end for the database is ACCESS97 and pulling up 20K records makes a huge performance hit. For the form in question I am using PASSTHROUGH type query (the one that just passes everything straight to server without ODBC). NOTE: souce_for_inquiries_form is the join table and is searchable in the from (it feeds a...
0
1215
by: gord barq | last post by:
I have this query which does a left outer join and it takes forever (like half a day). Here are the results of an explain analysis. mysql> explain SELECT count(searchresult.title) AS number, campaigntrack.title, tracknum, trackid FROM campaigntrack LEFT OUTER JOIN searchresult ON searchresult.title = campaigntrack.title WHERE campaigntrack.albumid = 1 GROUP BY title ORDER BY tracknum;...
0
1775
by: Joseph Norris | last post by:
Group, 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
0
2368
by: Soefara | last post by:
Dear Sirs, I am experiencing strange results when trying to optimize a LEFT JOIN on 3 tables using MySQL. Given 3 tables A, B, C such as the following: create table A ( uniqueId int not null default 0 auto_increment, a1 varchar(64) not null default '',
0
509
by: Eric B. | last post by:
Hi, 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...
2
790
by: Fabien Penso | last post by:
Hi. I need a little help to optimize requests on a table, and I have no idea how to do it (I optimized already a lot other table, but this one is a pain). My table looks like : CREATE TABLE comments ( id int(11) NOT NULL auto_increment, subject varchar(80) NOT NULL default '', timestamp timestamp(14) NOT NULL,
2
1457
by: Thanos | last post by:
Hello all, can someone advice me some links/infos on how to optimize MySQL server to execute very complex queries ? My configuration is as follows : P4 2.8Ghz/512MB running on Fedora Core 1 with latest updates, 2xHDD 36Gb SCSI 10000rpm (RAID 1), MySQL 4.0.22 configured with my-large.cnf, frontend application written in PHP 4. I need to execute complex queries using multiple joins/unions on large tables (more than 20,000/30,000 records)...
4
3498
by: Got2Go | last post by:
Hello Group, 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.
1
1497
by: coyote2002 | last post by:
Hi, I have big problem with mysql 4.0.18 . Because my database is growing up, every night records that are older than some date are deleted. But size of database on disk isn`t smaller after this operation. There are some solutions to free space by OPTIMIZE TABLE command, but this command when executes, does temporary copy of database. How can I free memory and avoid doing temporary copy of database ( because I don`t enough free space for...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10379
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.