'Copy To Tmp Table' Is Taking For Ever To Execute A Query
We have a query when run on large systems, it takes for ever to return the results. When we execute the query we notice that it takes a very long time in state - 'Copy to tmp table' but server doesn't get hung. Eventually it will return the data.
Following is the query:...
View Complete Forum Thread with Replies
Related Forum Messages:
Nested Select Statement Taking Hours To Execute
I am running a sub select statment so I can compare a couple of tables. If I run the statement from two test tables of 1000 records in each, it will take nine seconds to get the results that I need. However, if I take the same statement and point it to the two tables which contain all the data I need to run against (50560 and 161680 records respectively), it takes hours to run...how long I'm not sure. I fired the statement off yesterday afternoon @ 3pm and it is currently 11:30am the following day...the select statement is still executing. Does anyone have performance on something like this?
View Replies !
Table Query Taking WAY TO LONG
I have a query that is inner joined with another table based on country codes Select distinct Name.* from Name inner join Location on Location.key = Name.key and Location.cc in ('<list of countries here>'); The problem is when I have more than 2 country codes, the query takes forever... When I show processlist, it says converting HEAP to MyISAM ( this takes over an hour )... I've tried bumping up max_heap_table_size to 128M and tmp_table_size to 128M, but that only seems to delay the converting HEAP to MyISAM message.... Name contains about 3 million records and Location contains about 1.5 million records. Code:
View Replies !
Copy The Result Of A Query Into Another Table.
I am trying to make a select with a sum in it and group by account and copy the results in another table. As the site has the 4.0.25 MySQL version i guess i cant make subconsults. I thought of storying the results in vectors, but up to now it didnt work ...
View Replies !
Taking Colomns Of Data And Copying It To A Different Table
I've got two pieces of software running and I want to force users to only use the one log in so I though rather than trying to build a plug in I thought a cron job would no-doubt be easier. Now getting the data I want from the right table is easy enough for me but as the columns have different ID's I need to make it transpose it into the right columns... It runs but I suspect the second part of my code is failing. Code:
View Replies !
Optimizing Table - Count Taking Too Long
Could anyone help me with some advise on optimizing a table? It currently has 600,000 records and 'select count(*) from products where 1' is taking several seconds to return a result. Mysql is running locally on my development machine (XP) as a service and is version 5.0.24a The table is defined as follows: CREATE TABLE `products` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) default NULL, `description` text, `taxable` tinyint(1) default Ɔ', `sub_title` varchar(255) default NULL, `isbn` varchar(13) default NULL, `format` varchar(40) default NULL, `published_date` datetime default NULL, `pages` int(11) default NULL, `refundable` tinyint(1) default NULL, `refund_by_date` datetime default NULL, `publisher` varchar(255) default NULL, `bic_classification` varchar(10) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_products_on_isbn` (`isbn`), KEY `index_products_on_name` (`name`), KEY `index_products_on_bic_classification` (`bic_classification`), KEY `index_products_on_publisher` (`publisher`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
View Replies !
Execute Time Of A Query
I'm running a SELECT * query on a table with over 3,000 rows. I need to know the execute time on the query. PHPMyAdmin shows it to me, but because they automatically add a LIMIT 0, 30 I suspect the time is only for those 30 records. It also has a feature to prevent web server timeouts that prevents me from setting the LIMIT to 0, 3100. BTW, I'm programming in PHP. Does the time to run the query get automatically passed when PHP sends the query to MySQL? <? PHP $Query = "select * from my_table where 1"; $Result = MYSQL_QUERY($Query); ?>
View Replies !
How To Execute A Query From A File In OS X Leopard
I want to execute a query from within a file in OS X Leopard. The syntax (according to what I could find on the web) should be: mysql> . /Users/peterv/bin/test.sql; but it gives me this error: ERROR: Failed to open file '/Users/peterv/bin/test.sql;', error: 2 The file has the correct permissions.
View Replies !
Average Query Execute Time???
I have a query taking about 4 sec that gets only 18 records.. That's not good. What can I do to speen up my Query? <CFQUERY DATASOURCE="#datasource#" NAME="qry_job_search"> SELECT DISTINCT (t1.JobPostId), t1.Actionlkp, t1.Date, tbl_job_posting.*, tbl_job_post_requirements.*, tbl_employer_info.*, tbl_employer_url.*, tblkp_employment_type.*, tblkp_education_exp_lvl.*, tblkp_salary_range.*, tblkp_employment_exp_lvl.*, tbl_job_post_location.*, tbl_job_post_job_categories.JobCat, tblkp_countries.*, tblkp_prefectures.* FROM tbl_job_post_history AS t1 JOIN tbl_job_post_location ON tbl_job_post_location.JobPostID = t1.JobPostID JOIN tblkp_countries ON tbl_job_post_location.CC1 = tblkp_countries.CC1 JOIN tblkp_prefectures ON tbl_job_post_location.CC1 = tblkp_prefectures.CC1 AND tbl_job_post_location.PrefectureID = tblkp_prefectures.ADM1 LEFT JOIN tbl_job_post_requirements ON tbl_job_post_requirements.JobPostID = t1.JobPostID LEFT OUTER JOIN tbl_job_post_job_categories ON tbl_job_post_job_categories.JobPostID = t1.JobPostID JOIN tbl_job_posting ON tbl_job_posting.JobPostID = t1.JobPostID JOIN tbl_employer_info ON tbl_employer_info.UserID = tbl_job_posting.UserID LEFT JOIN tbl_employer_url ON tbl_employer_url.EmployerID = tbl_employer_info.EmployerID JOIN tblkp_employment_type ON tblkp_employment_type.ID = tbl_job_posting.EmploymentType JOIN tblkp_education_exp_lvl ON tblkp_education_exp_lvl.ID = tbl_job_posting.EducationExpType JOIN tblkp_salary_range ON tblkp_salary_range.ID = tbl_job_posting.Salarylkp JOIN tblkp_employment_exp_lvl ON tblkp_employment_exp_lvl.ID = tbl_job_posting.EmploymentExpType WHERE t1.JobPostId NOT IN ( SELECT DISTINCT (JobPostId) FROM tbl_job_post_history WHERE Actionlkp =4 AND date = ( SELECT MAX( date ) FROM tbl_job_post_history WHERE JobPostId = t1.JobPostId ) AND JobPostID = t1.JobPostID ) AND HistID = ( SELECT MAX( HistID ) FROM tbl_job_post_history WHERE JobPostID = t1.JobPostId AND Actionlkp =1 ) AND Date >= ( curdate( ) - INTERVAL 30 DAY ) <CFIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A EQ 0 AND SESSION.CITY_A EQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' <CFELSEIF (SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A EQ "") OR FORM.PREFECTURE NEQ 0> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' <CFELSEIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A NEQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' AND tbl_job_post_location.PostCity LIKE '%#SESSION.CITY_A#%' </CFIF> <CFIF (SESSION.CATEGORY_A NEQ 1) OR FORM.CATEGORY NEQ ""> AND tbl_job_post_job_categories.JobCat = '#SESSION.CATEGORY_A#' </CFIF> <CFIF (SESSION.KEYWORD NEQ "") OR FORM.KEYWORD NEQ ""> AND t1.Actionlkp = 1 AND (tbl_job_posting.JobTitle LIKE '%#session.Keyword#%' OR tbl_job_posting.JobDescription LIKE '%#session.Keyword#%' OR tbl_job_post_requirements.JobRequirements LIKE '%#session.Keyword#%') <CFIF SESSION.KEYWORD NEQ "" AND SESSION.PGV NEQ "brief"> <CFSET SESSION.PGV = "detailed"> </CFIF> </CFIF> <CFIF SESSION.EMP_TYPE_A NEQ 1> AND tbl_job_posting.EmploymentType = '#SESSION.EMP_TYPE_A#' </CFIF> <CFIF SESSION.EXP_LVL_A NEQ 1> AND tbl_job_posting.EmploymentExpType = '#SESSION.EXP_LVL_A#' </CFIF> <CFIF session.SRT EQ "D"> ORDER BY Date DESC <CFELSEIF session.SRT EQ "C"> ORDER BY tbl_employer_info.CompanyName <CFELSEIF session.SRT EQ "L"> <CFIF form.country NEQ 0> <CFIF form.prefecture NEQ 0> <CFIF form.city NEQ 0> ORDER BY tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_countries.CC1, tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSEIF session.SRT EQ "T"> ORDER BY tbl_job_posting.JobTitle </CFIF> </CFQUERY> Can anybody see a shortcut to get the same results??
View Replies !
Couldn't Execute '/*!40100 SET @@SQL_MODE='' */': Query Was Empty (1065)
I upgraded to MySQL 5.0, but the remote server still runs 3.23. Before I upgraded I was able to, in a local DOS-prompt, execute a mysqldump and get the database from the server to a file on my computer. Now, when I execute the same query, the remote server does not understand my command. This is what I execute on my local computer (simplified): C:foldermysqldump --add-locks --add-drop-table -h xx.xx.xxx.xx -u username -p database > "C:folderdb_downloaded.sql" This used to work, but after I upgraded I get the error message: Couldn't execute '/*!40100 SET @@SQL_MODE='' */': Query was empty (1065)
View Replies !
DBD::mysql::st Execute Failed: Lost Connection To MySQL Server During Query
I am using perl to connect to a database and then pull the rows off of the table one by one to manipulate the data. If I use a smaller table (~8 MB), I wait for around 20 seconds but then the table values are read just fine. However if I use a larger table (~30 MB), I wait for a while and then I get the message: DBD::mysql::st execute failed: Lost connection to MySQL server during query I have tried searching for the solution to this problem and haven't found anything that helps yet. I have changed the values of 'max_allowed_packet' and 'wait_timeout', with no effect. Any ideas?
View Replies !
Copy Table
I have a table which I have added a column to, I want to copy the value of the first column to the last column for all rows. Is there an SQL query to do this or should I use perl DBI?
View Replies !
Copy From One Table To Another
i have a table with x fields only one of which i am checking, namely a date field. I want to archive the rows into an identical table if the date is more than a year old. this has to be written in perl and here is what i have so far, some of it is pseudocode and i would appreciate it if you could clear some of it up as well as i havent touched perl in several years my $sth = $dbh->prepare("insert into table2 (*fields*) Values( select * from table1 where date_add(date, interval 1 year) < cur_date())"); my $sth2 = $dbh->prepare("delete from table1 where date < date_add(curdate(), interval -1 year)"); $sth->execute; $sth2->execute;
View Replies !
Copy The Table
What I wanted to do was run a SQL command to reduce numeric values in a fireld in a table to 75% of their current value. However, before i did that I wanted to creat a copy of teh original table in case I mess up the update query. (Background: The database is remotely hosted by my website provider, I am accessing it using the query analyser, having finally managed to successfully connect to it.) Thanks for any help, but please don't assume I know any SQL so please suggest complete SQL statements if you are kind enough to help - saying "use the XYZ Procedural widget" will get me no further I am afraid!
View Replies !
How To Copy Records In One Table?
does anybody know how to copy a record within one table? I am looking for some simple method similair to INSERT INTO orders SELECT * FROM orders WHERE Order_ID=256; Actually, this method does not work and I can not believe that MySQL does not offer some simple method how to do it. Keep in mind that I have a 60-field table. So, naming all fields is a pretty tedius task.
View Replies !
Copy Line Of A Table
Is it possible to copy 1 or more lines out of a table into another table? I am trying to create a kind of a mini backup sys. Every time a user erases/changes a table, I would like to document this change in another table. What I had in mind was simply to copy the line that was changed into another table and keep it for a certain period of time.
View Replies !
Copy Row Data In Same Table
I am trying to make a script that will copy data from around seven tables to another row in the table. This works fine for the first table using the insert INSERT INTO customers (list, of, fields) SELECT list, of, fields FROM customers where customer_id = customer_number but in the rest of the fields I dont see how it can work customer_id is the key and I want to make sure they all have the same key. Do I have to do a select first to get all the data where the id = cusomer_number then an insert a new record into the table with the new customer_id generated from the first insert?
View Replies !
Searching A Copy Of A Table
Code: CREATE TABLE `submitted_answers` ( `id` int(11) unsigned NOT NULL auto_increment, `survey_id` int(11) unsigned NOT NULL default '0', `question_id` int(11) unsigned NOT NULL default '0', `answer_id` int(11) unsigned NOT NULL default '0', `other_value` text, `user_id` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`id`), KEY `user_id` (`user_id`) ) TYPE=MyISAM One of the questions in a survey asked about the users age. I have now been asked to pull the other answers out by how the users answered the age question. I've tried a few different ways of searching a copy of the table but the numbers being returned aren't what I'm expecting. I'm not sure what I'm doing wrong. Here's my latest try that's giving me a number that's much too large. Code: SELECT count( tbl1.id ) AS count, answers.answer_text FROM `submitted_answers` AS tbl1, `submitted_answers` AS tbl2, answers WHERE tbl2.question_id =2 AND tbl2.answer_id =7 AND tbl2.user_id = tbl1.user_id AND tbl1.answer_id =1 AND tbl1.question_id =1 AND tbl1.answer_id = answers.id GROUP BY answers.id The ids I have listed for tbl2 are selecting (or at least I think they are) how the user answered the question about age. The example shown (tbl2.question_id = 2 AND tbl2.answer_id = 7) would be the users that said they were 50+. I'm then (once again, I think I am) relating the 2 table copies by user_id to match up the rows and getting how the users in tbl2 answered the question in tbl2. As I said, this query is giving me much bigger numbers than could be true and I'm not sure why.
View Replies !
Copy Column From One Table To Another
I have managed to get: update table_A , table_B set table_B.col_1 = table_A.col_1 where table_B.col_# = table_A.col_# to work on PHPMyAdmin 2.6.1-pl3 with MYSQL 4.0.16 but it will not work on PHPMyAdmin 2.6.0-pl3 with MYSQL 3.23.58;
View Replies !
Copy Table With Autoincrement
I have tried a lot to copy a table with php, but I can't: I tried first: CREATE TABLE copy SELECT * FROM table but it doesn't copy autoincrement or primary key. Deleting the autoincrement column, and then assigning it, does however makes an auto_increment column, but the values doesn't correspond with the original, because some posts where deleted there, and then the auto_increment values are higher. Then I tried to assign those two values later, by first truncating. CREATE TABLE copy SELECT * FROM table"; $sql2="TRUNCATE TABLE copy"; $sql3="INSERT INTO copy SELECT * FROM table"; $sql4="ALTER TABLE copy ADD PRIMARY KEY (id)"; $sql5="ALTER TABLE copy CHANGE `id` `id` INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT"; $sql6="ALTER TABLE copy AUTO_INCREMENT=$maxid but that doesn't work either. Isn't there a simple way to copy a table including the primary key and the autoincrement with php?
View Replies !
Copy Large Table?
I want to copy just part of a very large table from one database to another database. The table contains several million of rows. So far the only thing I can think of is using MySql dump. However, that will give me all the rows in that table, right? But I just want to grab 1000 rows to do testing.
View Replies !
Copy Table To Another Database
I have two tables and I'd like to copy some contents of table 1 to a specific field table 2. Their (the tables) purposes are the same, but the structure is different. There are some fields present only in table 1 and others only in table 2. Is this possible?
View Replies !
Copy Record From One Table To Another?
I've successfully installed and created a database for my company's web portal, which contains a Staff Directory. The thing is, I need a second data base with for the former staff. Is there a way to write a SQL statement that will delete the record from the current employee table, and add it to the former employee table?
View Replies !
SQL-Statement To Copy A Table Into A New One
i want to copy many records from one table into a new one. I found only the statement to export to an file and reimport them, but i don't like this version. Example: select * from abc where Status = "C" into outfile "abc-c"; truncate table abc-c; load data infile "abc-c" into abc-c;
View Replies !
Copy And Rename Table
I have a table that I'm using as the 'default' table to be used in a game creation When a new game is created, I'd like to be able to copy the table and rename it, something like game_map_29. The 29 will be the variable generated for the next game. The new game_map table will than be modified as the game progresses. Can someone maybe give an example on copying and renaming table?
View Replies !
Copy Table Data
How can i copy all data from tmclktrx table into my_tmclktrx table. SELECT EMP_NO, `DATE`, SCHE_CODE, SCHE_TYPE, TREAT_AS, IN1, OUT1, IN2, OUT2, IN3, OUT3, HR_MIN FROM `tmclktrx` INSERT INTO emp_no, `date`, sche_code, SCHE_TYPE, TREAT_AS, IN1, OUT1, IN2, OUT2, IN3, OUT3, WORK_HOUR FROM my_tmclktrx can anyone help me repair the code.
View Replies !
Copy A Really Huge Table
I have a really huge table that I need to copy however using the Export function in MySqlAdmin does not work because it "times out". All I really need to do is generate an SQL script that will, drop the table if it exists, create the table and its structure, and then insert the data line by line. Usually when you perform a command in MySqlAdmin through Internet Explorer the MySQL command line is displayed with the results. However, this does not happen when you export. Anyone know how to do this from the MySQL command line? In a nutshell: I need to backup a table to an SQL script file.
View Replies !
Copy/move Whole Table
I'm doing a conversion on a customer database and I'd like to take this chance to a lil learning I have v4_customer: v4_id | login | points and v5_customer: v5_id | login I want to move it to customer_conversion: v5_id | login | points Is there a way to do a table wide join (or equivelant) on the field login and move all of the info to customer_conersion? The table is about 15,000 records. It will only be run once or twice on a development machine, but I figure if there's a better way to do it, why not learn. Is there a better way than to loop through each row?
View Replies !
Copy Field To Another Table
I have 2 tables and would like to populate field2 in table 2 with the user field from table1. All i can find is examples of UPDATE for moving data within the same table. How do I UPDATE field2 with data from Table 1?
View Replies !
I Need To Copy A Table To Another In The Same Database But With Filters?
I need to copy a table to another in the same database but with filters? SELECT * FROM table1 WHERE table1.field1 LIKE '%.gif%' Insert into table1.field2; Update table1.field2 Select * from table1.field1 WHERE `table1.field1` LIKE '%.gif%'; Insert into table1.field2 SELECT * FROM table1.field1 WHERE table1.field1 LIKE '%.gif%'; I hope that makes sense, any ideas?
View Replies !
Copy Table To Table In Mysql
I need to copy data from 2 tables and merge them in to 1 table that already exists. i need to extract a column called "bpo" and a column called "usr" from 2 different tables called anv and bpo and then copy them into a table called mybpo. I guess it shood look something like this: sql = "INSERT INTO mybpo SELECT usr FROM anv where usr ='" & session("usr") & "' and SELECT bpo FROM bpo "
View Replies !
Copy Rows From One Table To Another Table
One is the "main" machine and all the others will synch data up with it it once in a while. Is there a command to insert rows into one table on a different machine using the table on the current machine? Like.... Main Table 1 on main machine e.x. 192.168.1.1 name|email|listdate ------------------------ tom|a@b.com|1-1-2005 dick|c@d.com|1-1-2005 harry|e@f.com|1-1-2005 etc. Temp Table 1 on field machine e.x. 192.168.1.2 name|email|listdate ----------------------- larry|g@j.com|6-1-2005 mike|h@k.com|3-1-2005 fred|i@l.com|5-1-2005 i know you can do something like the following if they are both located on the same machine but i don't know how to structure the command for different machines: insert into real_table (col1, col2) select x, y from temp_table;
View Replies !
Command Line :: Copy Database Table
I'm looking for a command line call that can copy a database table (db1, table1) to another database (db2, table1).I know there has to be an easy way to do this but I can't seem to be able to find the magic syntax.
View Replies !
Copy Record Inside The Same Table With Differnt IDs
What I have to do is to copy a complete record inside the same table with a new ID. Normally this works: INSERT INTO THISTABLE SELECT * FROM THISTABLE WHERE id=4711 So I want to store the record with the id=7411 under a new given ID lets say 4578 I tried this INSERT INTO THISTABLE SELECT *, 4578 as id FROM THISTABLE WHERE id=4711 I expected that "4578 as id" would override the original id but do no work in my sense.
View Replies !
Table Name Case Lost On Copy Database
We make a manual copy of our database from our server (mySQL v5.0.32) to a local machine (mySQL v5.0.27). However the copy converts all tablenames from mixed to lower case. (All field names, on the other hand, retain their mixed case.)
View Replies !
What To Do To Copy[triple] A Table['land' To 'villas' To 'apts'] In Phpmyadmin
what to do to copy[triple] a table['land' to 'villas' to 'apts'] in phpmyadmin, not the contains ? CREATE TABLE `land` ( `photourl` VARCHAR( 40 ) NULL , `id` VARCHAR( 5 ) NOT NULL , `name` VARCHAR( 40 ) NOT NULL , `priceeuro` DECIMAL( 9, 2 ) NULL , `pricecyp` DECIMAL( 9, 2 ) NULL , `beds` VARCHAR( 1 ) NULL , `description` VARCHAR( 500 ) NULL , `location` VARCHAR( 20 ) NULL , `area` VARCHAR( 20 ) NULL , `detailsurl` VARCHAR( 40 ) NULL ) ENGINE = MYISAM COMMENT = 'Land for sale in Pafos';
View Replies !
|