How to make a MySql query faster?

Let’s learn how to make a MySql query faster. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

How to make my MySQL SUM() query more faster

I have about 1 million rows on users table and have columns A AA B BB C CC D DD E EE F FF by example to count int values 0 & 1 SELECT CityCode,SUM(A),SUM(B),SUM(C),SUM(D),SUM(E),SUM(F),SUM(AA),SUM(BB),SUM(CC),SUM(DD),SUM(EE),SUM(FF) FROM users GROUP BY CityCode Result 8 rows in set (24.49 sec). How to make my statement more faster?

Answer:

Use explain to to know the excution plan of your query. Create atleast one or more Index. If possible...

Read more

emma at Stack Overflow Mark as irrelevant Undo

Other solutions

Answer:

All MySQL user accounts can be made by querying "CREATE '[username]' @ '[server]' IDENTIFIED BY...

Read more

community wiki at wiki.answers.com Mark as irrelevant Undo

How to do this mysql query on 2 tables?

I have 2 tables, one named ARTICLE and one named COMMENTS. Say ARTICLE table contains … -ID - article And COMMENT table contains… -ID -article_id (which will be related to “ ID” in the articles table) -comment I have a simple...

Answer:

SELECT a.id AS "Article ID", COUNT(*) AS "Number of Comments" FROM article a JOIN...

Read more

TheMadPr... at Yahoo! Answers Mark as irrelevant Undo

WordPress Plugin Development: How can I set a MySQL query to specify the options table using a user defined prefix?

I have the following line in my plugin to remove transients from the database option table. $wpdb->query( "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_feed_%')" ); However, it won't work with sites which set a prefix...

Answer:

Use the global wordpress variable $table_prefix in your query: $wpdb->query( "DELETE FROM ...

Read more

Nicholas Pickering at Quora Mark as irrelevant Undo

How do I reduce MySQL query execution time from 90s to less than 5s or even ONE?

I am using MySQL database. When I execute a query which the main table(20 thousands of rows) is joined with the other 5 tables, it takes 90 seconds to return me the result. I then added indices into each of the criteria(where clause). Then the execution...

Answer:

Optimizing MySQL queries is a fairly straightforward process. To solve your problem would require a...

Read more

Juan Cristián Vera Huneeus at Quora Mark as irrelevant Undo

M$ no like MySQL

I need to get MySQL working with Visual Studio 2005. I come from the PHP world, and while I know C, C# is a new language to me. There's two issues. First, VS2k5 doesn't seem to allow me to add a MySQL (using Connector/Net 1.07) database as a project...

Answer:

Oh, and the reason that I can't switch to MsSQL is that this is a tool to do some important stuff with...

Read more

SpecialK at Ask.Metafilter.Com Mark as irrelevant Undo

How can I use PHP to display a MYSQL datetime value without displaying the seconds?

How can I strip the seconds off when displaying a MYSQL datetime variable, using only PHP commands, not MYSQL commands like "DATE_FORMAT"? I have a form where users enter a few dates and times. I don't care about seconds, just the year, month...

Answer:

And converting to a unix timestamp can be done with strtotime, like so: date("Y/m/d H:m",...

Read more

Bugbread at Ask.Metafilter.Com Mark as irrelevant Undo

$query command syntax problem with php (MySQL)?

When I try to make a MySQL query string ("SELECT Name, Desc, Link FROM Site") I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Desc, Link...

Answer:

Sorry im not being smart but none of that makes any sense to me.. What is an SQL version 4. 1. 22 standard...

Read more

Tom at Yahoo! Answers Mark as irrelevant Undo

MySQL and PHP Help with the Select Function?

I am making a 'Richest Person List' on my Website. This is the Code: <div class="box2"> <p class="chat">Richest Person of the Month!</p> <br></br> <?php // Make a MySQL Connection $host = "CENSORED...

Answer:

use sub query! select username, balance from iconomy where balance = (select max(balance) from iconomy...

Read more

GregoryI... at Yahoo! Answers Mark as irrelevant Undo

Mysql Regular Expression For Mobile Number?

the format must be (01 03 04 05 06 07 08 09)|(70 71 76)-XXXXXX where X can be any number from 0 to 9. A working example would be: 03-769112 or 71-682315 or 09-001241. I made myself a PHP regular expression that works very well for this and it's: "...

Answer:

This could be the technical issue... Report it to the service to get things fixed..... Good luck!

Read more

[E][M] at Yahoo! Answers Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.