All versions of MySQL (not Microsoft SQL Server). Please also add a version-specific tag like mysql-5.7 if that is relevant to the question.

learn more… | top users | synonyms

2
votes
2answers
753 views

MySQL - INSERT … SELECT .. FROM .. - Single transaction or transaction per row?

Question: I am currently working on a data migration. I need to migrate 2.5 million rows from one InnoDB table to another InnoDB table (with a different setup). I am using the following syntax to do ...
2
votes
2answers
3k views

Difference between show status and show global status in mysql

When I execute "show status" and "show global status" in MySQL at interval of 5 seconds , I got set of 291 results each time. But, value of some parameters are different. Below are the list of those ...
1
vote
1answer
493 views

MySQL: Is it possible to have an IF subquery?

I'm attempting to run a subquery inside of an if statement used in the SELECT, but I'm getting an error. I've never needed to do something similar before so I've never tried this until now. Here is ...
0
votes
1answer
43 views

is it possible to set engine for database (not the tables)?

There are about 250 tables in my database and they all have InnoDB engine. I imported them into a server. They were imported and were displayed in the tree structure of phpmyadmin (under the ...
3
votes
1answer
207 views

Will a change from MyISAM to InnoDB require SQL query changes in MySQL?

I am planning to change some large MyISAM tables in my MySQL database into InnoDB. This is because I am having performance problems where large and complex updates (updating a few million rows in one ...
1
vote
1answer
299 views

Need to optimize simple SELECT query for InnoDB table with 2million rows

I'd like to make this query the fastest possible, since it's called really often. SELECT login_events.id FROM login_events WHERE ( DATE(created_at) >= DATE(CURRENT_DATE) AND person_id = 1 ) ...
-1
votes
2answers
308 views

What database should I use to create a webmail service like gmail? [closed]

I planned to use python for my frontend with django framework. But for backend, I have no idea which database I should use. Since it involves plenty of reads and writes can someone point me in the ...
3
votes
2answers
4k views

MySQL Replication Troubleshooting

Here's what I did. On the master, change /etc/my.cnf: [mysqld] server-id=1 log-bin=mysql-bin innodb_flush_log_at_trx_commit=1 sync_binlog=1 Save and restart mysql, then log in. >GRANT ...
0
votes
1answer
103 views

Is it possible to optimize this query? Or any recommendations to speed it up?

After looking at my mysql slow log file I see that almost every entry there is related to this query: SELECT n.nid AS nid, AVG(v.value) AS rating FROM node n LEFT OUTER JOIN votingapi_vote ...
5
votes
2answers
2k views

Partitioning a table vs moving entries to another table

I don't understand how partitioning helps me more or less than using a separate table to store older records. I need to maintain a list of stock entries along with historical records about the stock. ...
0
votes
1answer
109 views

Get all items from list table which don't have a successful log entry for 'sent' in log table

How might one retrieve items that when joined either don't have a specific field (sent), or if they do have that field (sent) then they have an additional field (failure_reason) as well for every sent ...
0
votes
2answers
1k views

Getting table definitions on the command line in MySQL [closed]

I am new to MySQL. I am trying to get table definitions from the database server (4.0.26). I tried below steps to get information, running cmd as an administrator: c:\> cd mysql\bin\ ...
5
votes
2answers
844 views

Optimize queries from MySQL SP/Triggers/Functions

I have to investigate a MySQL Production server,While investigating I found a DELETE query in "SHOW PROCESSLIST" which was taking more than 400 second in preparing state, I tried to find the query in ...
1
vote
2answers
1k views

InnoDB + TokuDB fills up RAM then start swapping

I'm trying to face difficulties with my database lately. I've migrated from MyISAM to TokuDB v7.0.4 and InnoDB. I'm using MariaDB - 5.5.34-MariaDB-1~wheezy-log. My problem is that MariaDB fills up RAM ...
1
vote
2answers
173 views

Indexes slowing Insertions(Can't use Explain Insert to Analyse)

I have a MySQL database, I am parsing files from a log and inputting it inside. So far including a simple 4MB file in the database could take me about 4 minutes to insert ! and i have about 10,000 ...
0
votes
1answer
73 views

Disk page size for MySQL and MySQL cluster [closed]

As I know database reads data from disk in some constant page size (even if one byte is needed, whole page will be copied from disk to memory). What are disk page sizes for MySQL and MySQL Cluster? Is ...
3
votes
3answers
8k views

Purge old records from mysql ibdata1 file

Is it possible to purge old records from an ibdata1 file without taking down the database attached to it? Records that have been deleted from the database are still present when I scan ibdata1 for ...
1
vote
1answer
543 views

Count records in a related table

I have three tables: items, members, subscriptions. One item can be get by 1 or more members (one member can get more items), so subscriptions represents the many-to-many relationship between items ...
0
votes
1answer
145 views

unique ID for multi tabel? (MySQL) [closed]

I have a table 'article' and each of these articles belongs to one of three different topics (topic_a, b and c). I also have a table for each of these topics with various fields. How can I connect ...
3
votes
1answer
1k views

LOAD DATA INFILE fatal error encountered

I use this query for loading sql data from my pc to localhost mysql database.(version 5.0.10 working witj XAMPP) The query is as below: cmd = new MySqlCommand("LOAD DATA LOCAL INFILE '" + filename + ...
2
votes
1answer
3k views

mysql db backup excluding specific tables

Are there any mysql scripts for taking a database backup by excluding specified tables? Also, what is the best way to take backup of a running mysql system?
0
votes
2answers
348 views

How can I set columns for an entire table in one UPDATE based on the SUM of a join table column?

I have tables companies and employees: explain companies; +--------------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default ...
3
votes
3answers
350 views

Joining and filtering two sets of the same table

I guess this is an easy and stupid question. Consider this MySQL purchase table (where p_id is autoincremented): +---------+-------------+---------------+---------+ | p_id | item_id | user_id ...
0
votes
1answer
160 views

Mysql replication dump without down time? empty sql file

I try to create dump as replication master data and use followed command to create dump, but sql file only contains paramters and there is no data and structure. The command is : mysqldump ...
1
vote
0answers
128 views

Best practices for ranking records in flexible way

Suppose we have 10000 records of any product. User search on our website with his given criteria. so we output search results based on given criteria. Now Admin want to rank products in search. so ...
0
votes
1answer
815 views

Mysql Alias IF statement

How do you query something like if parent = 0 then alias is network_id else alias is group_id Is this possible with only queries?
2
votes
2answers
5k views

Mysql match on two columns and get count

How do I get a count of? +---------+-------------+ | col1 | col2 | +---------+-------------+ | Joe | April | | Fred | May | | Sam | April | | Joe | ...
1
vote
2answers
1k views

Mysql. Block/disconnect slow queries

I am experiencing issue. Someone 'attacked' my server: simply by searching the same phrase with multiple requests. As it is text search request and database indices are not used, the engine searches ...
4
votes
1answer
1k views

Which are the minimum privileges required to get a backup of a MySQL database schema?

Which are the minimum privileges required to get a backup of a MySQL database schema? I am interested only on the schema, not on the data. Are SELECT privileges required?
1
vote
0answers
234 views

mysql/mariadb: ifnull changes collation

It seems that 'ifnull' changes the default collation that is set to be used. I have tried on both mysql and mariadb: Server version: 5.5.34-MariaDB-1~precise-log mariadb.org binary distribution ...
0
votes
1answer
747 views

MySQl master - master replication not working [closed]

I'm trying to setup a master - master setup and I see both masters connect to each other in workbench: server 1: -- Thread Id: 112 -- User: slave -- Host: 207.244.73.38:55164 -- DB: None -- ...
0
votes
0answers
243 views

I can't get MySQL server to stop running

The output from MySQL Workbench when I try to stop it is: Executing '/usr/local/mysql/support-files/mysql.server stop' 2013-12-23 21:08:29 - Stop server: ERROR! MySQL server PID file could not ...
0
votes
0answers
72 views

How do I save file data to my newly mounted SSD in mysql innodb continually?

I've recently mounted a new SSD since my disk's empty space had less than 10% (mysql unbuntu linux) and this is what I did in my.cnf file to save data to my new path: innodb_buffer_pool_size=2G ...
0
votes
2answers
344 views

bind-address how does it work in mysql

I have a mysql running with bind-address "10.4.0.211". From the documentation, I understand it like, the server accepts connections only from the IP - 10.4.0.211. But I could able to connect to ...
3
votes
1answer
8k views

Maximum possible memory usage: 16.2G (874% of installed RAM)

Why the MySQL is saying that can use about 16GB of RAM even if my server has only about 2GB? # ./mysqltuner.pl >> MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net> >> Bug ...
2
votes
1answer
757 views

MySQL with high CPU and memory usage

here we have a VPS with 3.2GHz quadcore processor with 2GB of RAM and 4GB of SWAP which need to work with a high intensive legacy system (read: bad coded). The main problem is that the CPU (~80 - ...
2
votes
2answers
1k views

How to SELECT rows with time duration stored in varchar column?

There is a column in table defined like this : duration varchar(10) It has value for duration of a MP3 file stored in it like : 52:19 (Minutes : Seconds) How can I create a SQL query, for ...
3
votes
2answers
6k views

Full outer join does not work for two small tables, error 1064

folks. I am currently exploring the capabilities of MySQL while doing simple exercises with diverse queries. I was reading the following article that explains how table JOIN works: ...
3
votes
2answers
196 views

optimal size of innodb buffer pool

I read a lot of optimal number of innodb_buffer_pool_size and people say it must be larger with 10% than the innodb tables size, what is 60M. Accordyngly this the optimal size of the buffer is about ...
1
vote
1answer
6k views

Query State hangs on sending data

For some reason, the query state hangs on "Sending Data" (using show processlist;) and I have no idea why. This is the table creating script: CREATE TABLE IF NOT EXISTS `esp_game` ( `gameID` ...
1
vote
1answer
4k views

QUERY RECORDS WITHIN 48 hours

I am storing some data intro a mysql database like this: ID | DATE | INFO ----------------------------- 1 | 1389384821 | blabla 2 | 1389384821 | blabla2 3 | 1389384821 ...
0
votes
1answer
657 views

Shopping cart schema with multiple product tables

I have a shopping cart table used to store customer id and product id of their chosen items. However I have multiple product tables, for example cars, books, houses. I started out with one table but ...
1
vote
1answer
2k views

Using OFFSET in a large table by a simple sub-query

The slow performance for using OFFSET in large table has been widely discussed in various blogs, and the most efficient way is to use an INNER JOIN as SELECT * FROM table INNER JOIN ( SELECT id FROM ...
1
vote
1answer
3k views

Analyse MySQL General Query Log in Real-time?

We want to use mysql general query log to do real-time monitoring and auditing. Currently our approach is: set general_log=on; sleep 15m; set general_log=off; scp & rm xxx.log; set ...
0
votes
1answer
53 views

Should the value of a select max be indexed when the where clause is already indexed

I have a customer_orders table in a schema designed to be shared between multiple companies. Each customer_order has an invoice number that should always start at 1 and increment based on company ...
2
votes
0answers
2k views

MySQL Queries taking too long to execute

I have a database table, with 300,000 rows and 113.7 MB in size. I have my database running on Ubuntu 13.10 with 8 Cores and 8GB of RAM. As things are now, the MySQL server uses up an average of 750% ...
1
vote
1answer
89 views

normalization of data and duplicate rows

All right, this is a hobby question, so nothing critical if I don't get a quick response. But you guys have been so good at helping me, I thought why not chance it again. I am creating a db that can ...
1
vote
0answers
162 views

join performance, index vs. index+foreignkey

I'm using an orm framework that handles data (and its integrity) on top of mysql. So far I ignored foreign keys because the orm handles that just fine. I recently read that foreign keys can enhance ...
-1
votes
2answers
5k views

Query to compare two rows in MySQL and make an UPDATE

I have a table (MySQL) like this: ID | AnotherID | Number1 | Number2 | Data 1 A 101 199 Lorem 2 A 102 ...
0
votes
0answers
90 views

Why does a scrambled junction table destroy the speed of my query?

I have two schema in a MySQL database, one containing raw data in MyISAM tables and the other containing the results of some processing tasks performed on the raw data, also in MyISAM tables. For ...