473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to optimise a mysql table using php

I am deleting rows before inserting new one and i get Overhead problems. what can i do do repair the table after i delete the row. i have been trying for ages but i could not do it. this is the code for inserting.

when i use OPTIMIZE TABLE item, it does not work.

Expand|Select|Wrap|Line Numbers
  1.         // delete before inserting //////////////////////////
  2.  
  3.         $query = "SELECT COUNT(*) as num FROM orderr WHERE order_reference_number='".$newReference."' ";
  4.         $total_pages = mysql_fetch_array(mysql_query($query));
  5.         $total_pages = $total_pages[num];
  6.  
  7.         if ($total_pages = "1")
  8.  
  9.         {
  10.  
  11.         $sql="DELETE FROM orderr WHERE order_reference_number='".$newReference."' ";
  12.        //echo $sql;
  13.         mysql_query($sql);
  14.  
  15.         $sql="DELETE FROM item WHERE order_reference_number='".$newReference."' ";
  16.        //echo $sql;
  17.         mysql_query($sql);
  18.  
  19.         }
  20.  
  21.         ////////////////////////////////////////////////////
Feb 5 '10 #1
2 1471
Atli
5,058 Expert 4TB
Hey.

What do you mean by "Overhead problems"? Could you elaborate on what the problem is exactly.

Why would you need to "repair" the table after a DELETE? Do you mean that you want to re-use an ID generated by a AUTO_INCREMENT column?
Have you tried using the REPLACE command instead of deleting and inserting manually?
Feb 5 '10 #2
ok. i managed to get it working.

Expand|Select|Wrap|Line Numbers
  1.  
  2. [PHP]
  3.  
  4.         if ($newReference == "A001")
  5.         {
  6.         $opt = "OPTIMIZE TABLE item";
  7.         $opt_table = mysql_query($opt); 
  8.         }
  9.  
  10. [/PHP]
  11.  
  12.  
I have got another small question. how can i add "B001" , "C001" , "D001" , "E001" ........ and so on till "Z001" to this if statement.
Feb 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: Jasper Bryant-Greene | last post by:
Hi I have this query: SELECT id, name, YEAR(born) AS year FROM people WHERE DAYOFMONTH(born) = 7 AND MONTH(born) = 12 ORDER BY year DESC, name
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
2
by: Hervé Piedvache | last post by:
Hi, I have may be a stupid question, but I'm a little surprised with some explains I have, using date fields ... I would like to understand exactly when index are used ... I'm using...
1
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work....
1
by: paulq182 | last post by:
PLEASE HELP ME WITH MY CODE?? import java.sql.*; import java.io.*; class min_filmdb_rel_mysql { public static void main (String args ) throws SQLException, IOException {
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.