I have a series of tables in which the data can be refreshed from a file.
Before refreshing the data, some of the tables are cleared using either TRUNCATE or DELETE.
If TRUNCATE is used, any index which is not PRIMARY or UNIQUE appears to be disabled and is not updated when new data is inserted into the table.
Performing an OPTIMIZE reactivates the index.
If DELETE is used instead of TRUNCATE, this problem does not occur.
Does anyone know if this a fault, a feature, an option which can be changed?
MySQL version 4.1.20
15 7216 pbmods 5,821
Recognized Expert Expert
This probably has something to with the fact that TRUNCATE actually drops and recreates the table. It does not seem like it is supposed to do that, though, and I wasn't able to Google much about it. Try to see if you can reliably reproduce this behavior in a separate database.
You should also be able to re-enable the indexes by doing: -
ALTER TABLE `tablename` ENABLE KEYS
-
Motoma 3,237
Recognized Expert Specialist
MySQL 4.1 has a lot of quirky 'features' in it. I would suggest upgrading to 5.
MySQL 4.1 has a lot of quirky 'features' in it. I would suggest upgrading to 5.
Thanks for the advice, but not currently an option.
I'm running on a shared hosting system and because I was losing several indexes, my queries started performing badly (MySQL server overload), and my MySQL database was turned off - twice!
It was only after the second occurrence that I managed to get enough information to find out what was causing the problem.
Oh, and I have only just recently signed up with this host - the previous one suspended my account completely (e-mail, web, FTP, My SQL), again for MySQL server overload, presumably for the same reason.
I have a workround now, but you can see why I'm keen to understand the cause.
Motoma 3,237
Recognized Expert Specialist
I have been in the same boat. It is really frustrating when you have to use an outdated version of MySQL, especially if you are stuck with one that does not support stored procedures or subqueries.
This probably has something to with the fact that TRUNCATE actually drops and recreates the table. It does not seem like it is supposed to do that, though, and I wasn't able to Google much about it. Try to see if you can reliably reproduce this behavior in a separate database.
You should also be able to re-enable the indexes by doing: -
ALTER TABLE `tablename` ENABLE KEYS
-
After experimenting, it is not the TRUNCATE which disables the INDEXes - they are not activated from the time of the CREATE TABLE.
I created a copy of my table in another database.
There is a PRIMARY INDEX, a UNIQUE INDEX and 5 other INDEXes.
Running an OPTIMIZE TABLE or ANALYZE TABLE on the empty table returns 'Table is already up to date'.
INSERT INTO one or more rows and the PRIMARY INDEX and UNIQUE INDEX are updated - the other INDEXes are not.
ALTER TABLE `tablename` ENABLE KEYS has no effect .
Perhaps the INDEXES are not 'disabled', but they are certainly not active.
The only actions that seems to activate the INDEXes is OPTIMIZE TABLE or ANALYZE TABLE.
Once one of these is done, the INDEXes are maintained after any UPDATE, INSERT or DELETE.
TRUNCATE obviously drops and creates the table, and everything starts again.
Confused...
Motoma 3,237
Recognized Expert Specialist
Could you build a simple test case that demonstrates this behavior? I would like to test this out, if you could write up the SQL statements starting from your create table, I would be very appreciative.
Could you build a simple test case that demonstrates this behavior? I would like to test this out, if you could write up the SQL statements starting from your create table, I would be very appreciative.
I discarded the scripts and the data that I used to perform the test, but it was based on the table that had originally caused me the problem. There were 35 columns in this table, and some of it was sensitive data.
I will look at recreating a simple test case when I get chance, possibly later today.
Test case, simplified to the minimum below: - - DROP TABLE IF EXISTS Tester;
-
-
CREATE TABLE Tester
-
(
-
ID INT(11) NOT NULL,
-
F1 VARCHAR(10) NOT NULL,
-
F2 VARCHAR(10) NOT NULL,
-
F3 VARCHAR(10) NOT NULL,
-
F4 VARCHAR(10) NOT NULL,
-
F5 DATETIME NOT NULL,
-
F6 TEXT NOT NULL,
-
PRIMARY KEY (ID),
-
UNIQUE I1 (F1, F2),
-
KEY I2 (F3, F4),
-
KEY I3 (F4),
-
KEY I4 (F1, F3, F4),
-
KEY I5 (F1, F4),
-
KEY I6 (F5)
-
)
-
TYPE = MYISAM;
Result: (PRIMARY and I1 cardinality 0; I2, I3, I4, I5, I6 cardinality NULL) - INSERT INTO Tester VALUES ('1', 'A1', 'A2', 'A3', 'A4', '2007-05-29', 'A5');
Result: (PRIMARY and I1 cardinality 1; I2, I3, I4, I5, I6 cardinality NULL)
Result: (PRIMARY, I1, I2, I3, I4, I5, I6 all cardinality 1)
Note: ANALYZE TABLE Tester; has the same effect as OPTIMIZE TABLE Tester; - INSERT INTO Tester VALUES ('2', 'B1', 'B2', 'B3', 'B4', '2007-05-29', 'B5');
Result: (PRIMARY, I1, I2, I3, I4, I5, I6 all cardinality 2)
Motoma 3,237
Recognized Expert Specialist
Thank you. I was able to reproduce this behavior in MySQL 4.0.16-nt.
One thing I noticed, however, this behavior is not present with the InnoDB database engine.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Patrick L. Nolan |
last post by:
Our Tkinter application has a big ScrolledText widget which is
a log of everything that happens. In order to prevent people
from making changes, we have it in DISABLED mode except when
the program wants to write a new entry. This works OK, except
that sometimes we want to copy out of piece of the contents and
paste it in another window. ...
|
by: Rafal Kedziorski |
last post by:
hi,
I have this table:
CREATE TABLE `category_tree` (
`category_tree_id` BIGINT NOT NULL AUTO_INCREMENT,
`parent_id` BIGINT,
`mandant_id` SMALLINT NOT NULL,
`partner_id` SMALLINT NOT NULL,
`class_id` VARCHAR ( 32) NOT NULL,
|
by: David Wake |
last post by:
I have two radio buttons and two checkboxes in a form.
I'm trying to write some code so that when a radio button is selected,
its corresponding checkbox is disabled.
My code looks like this:
function radioClicked(index)
{
document.table_config_form.my_checkbox.disabled = true;
|
by: Stu Carter |
last post by:
Hi,
I have an aspx page where some controls are initially disabled by the
code-behind 'Page_Load' event. I want these controls to be dynamically
enabled when the user checks a checkbox. Because I don't want a post-back,
I added some javascript to do this
However, using client-side JS, I cannot enable any controls that have been...
|
by: Hervé Piedvache |
last post by:
Bug or problem with PostgreSQL ?
version
---------------------------------------------------------------
PostgreSQL 7.4.3 on i686-pc-linux-gnu, compiled by GCC 2.95.4
select * from my_table;
id | login | passwd | state | email
--------------+-----------+------------+-------+------------------
(0 rows)
| |
by: rcamarda |
last post by:
As part of my data warehouse nightly build, I truncate my tables in my
target database.
As example, I find it is much quicker to do a bulk API load of 13M
records and to do an update/insert of 100K rows. I also drop the
indexes before the builds and reindex after. Thats an aside.
What I am wondering is how is this impacting the statistics? Do...
|
by: rhepsi |
last post by:
Hii all,
I have a project where before i upload the data from 1st database to 2nd database, im truncating the 2nd database and then trying to upload...
In this process, wat i found was that: My records in the database are something like:
`tbl_workers` (`wo_worker_id_pk` bigint(11) unsigned NOT NULL auto_increment,
`wo_worker_code`...
|
by: Eric Davidson |
last post by:
I am try to find a way to get load to reject a record if the data is
too large and not just truncate it.
eg.
c:\temp\fred3.txt
------
a23456789012345678901234567890
b23456789012345678901234567890b234567890
|
by: Timothy Madden |
last post by:
Hello
I see there is now why to truncate a file (in C or C++)
and that I have to use platform-specific functions for
truncating files.
Anyone knows why ? I mean C/C++ evolved over many years now,
and still, people making _the_ standards never decided to
include such a function. Even in POSIX it was included only
in recent versions,...
|
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...
|
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. ...
| |
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |