updating the multi-line record problem, At first you might think of a way to use loops to execute multiple UPDATE statements, like the following example of a PHP program: foreach ($display _order$id$ordinal$sql=$ordinal$id"; mysql_query ($sql); } There is nothing wrong with this method, and the code is easy to understand, but in the loop statement executes m
passed to the query Executor, which introduces the storage engine (Storage engine), which is queried by the executor (query Executor) through OLE as an interface to the access method (Access Methods).access Method (Access Methods)The access method is to provide a storage structure for your data and indexes, as well as a batch of code to modify the interface through data retrieval or data. It contains all t
:
Reduce the size of the index
Indexes are reduced, resulting in faster queries to the index
Small index for adding and removing changes in the maintenance performance will be higher
For example, the following statement: After we have set up a clustered index for it: At this point we add filter conditions to form a filtered index: From the above we can see that the use of filtered index of the scene to be related to the specific business scenario, for a large number of
if the data is retrieved by index criteria, otherwise,InnoDB The table lock will be used! If the corresponding SQL statement does not go through the index, the entire table will be locked out. MysqlMySQL supports row and table locks only under the InnoDB engine. The default engine for MySQL is InnoDB.The MySQL default mode of operation is autocommit auto-commit mode (value 1). This means that unless a transaction is explicitly started, each
DBAs, but we have to consider production issues when writing code. If we don't do this at the early stage of development, DBAs will only force us to rework after discovering it.
We usually say that database debugging is a technology and an art, because there are few ready-made rules that can adapt to all problems, the problem you solve on one system may not be a problem on another system, and vice versa. No answer is correct when it comes to query ad
Execute the following SQL error [ERR] 1093-you can ' t specify target table ' UU ' for update in FROM clause:UPDATE Sellmanagement_agency_user UUSET uu. ' Status ' = 1WHEREUu.id in (SELECTU.idFromSellmanagement_agency_user uLeft JOIN sellmanagement_agency_type t on u.type_id = T.idWHERET.type = 3and U. ' Status ' = 0)The result of select is passed through the intermediate table select again, thus avoiding t
, if a null value is contained, we do not want to be indexed, or according to the specific business scenario, we do not want to index some data. You can:
Reduce index size
The index is reduced to accelerate the query of the index.
Small indexes provide higher maintenance performance for addition, deletion, and modification.
For example, the following statement:
After we create a clustered index for it:
In this case, we add
. The FULLSCAN clause specifies that all data in the table is scanned to collect statistics, while the sample clause is used to specify the percentage of rows sampled or the number of rows sampledIn SQL Server 2005, the database Options Auto_update_statistics_async provides statistical information for the asynchronous Update feature. When this option is set to ON, the q
sampled or the number of rows sampledIn SQL Server 2005, the database Options Auto_update_statistics_async provides statistical information for the asynchronous Update feature. When this option is set to ON, the query does not wait for statistics updates to compile. The outdated statistics are placed in the queue and are updated by the worker threads in the back
filtering condition is that cid is greater than 1, and cid is greater than 2.Select count (*), cid, sex from student group by cid, sex having cid> 1 and max (cid)> 2;Ø nested subqueryA subquery is a query nested in a select, insert, update, or delete statement, or other subqueries. Subqueries can be used wherever expressions are allowed. A subquery is also called an internal
This is often the case when developing databases:When a piece of data does not exist, insert the data. If the primary key of the data already exists in the database, update the data.How do you do this? First, query data based on the primary key, and then determine whether there is data. If there is data, update the field; otherwise, insert the data.The disadvanta
Query, delete, insert, query, sort SQL statementHere we provide query, delete, insert, query, sort totals sum average max minimum SQL statement OH.Selection: SELECT * FROM table1 whereInserting: INSERT INTO table1 (field1,field2)
Tags: type error associated recommendation management will rom Ora no(Transferred from http://blog.csdn.net/sforiz/article/details/5345359) We have to do not only write SQL, but also to write good performance of SQL statements.(1) Select the most efficient table name order (valid only in the rule-based optimizer):The Oracle parser processes the table names in the FROM clause in a right-to-left order, and th
= $id";
mysql_query ($sql);
}
There is nothing wrong with this method, and the code is easy to understand, but in the loop to execute more than one SQL query, in the system optimization, we always want to reduce the number of database queries as much as possible to reduce resource consumption, while increasing the speed of the system.
Fortunately, th
Essential SQL query optimization techniques to speed up Website access and SQL access
In this article, I will introduce how to identify queries that cause performance problems, how to locate their problems, and how to quickly fix these problems and other methods to speed up the query.
You must know that a website with
I have been learning about SQL Server recently. I took a test yesterday. It's really not easy. In particular, some complex queries. It makes me dizzy. However, it is also because your knowledge is not solid enough. So today I reviewed the addition, deletion, modification, and query of the T-SQL statement. Many of them are indeed forgotten. Write the result. Don't
The recent use of SQL Server in project-on-line usage has found that frequent updates and frequent queries cause deadlocks in high concurrency situations. Usually we know that if two transactions are inserting or modifying data on a table at the same time, it will occur when the X lock on the table is requested and has been held by the other party. Because the lock is not available, subsequent commits cannot be executed so that both parties begin to
Label:first, Getting started with SQL statements1. SQL statements are statements that are specific to the DBMS "talk", and the SQL syntax is recognized by different DBMS.2. The string in the SQL statement is enclosed in single quotation marks.3. SQL statements are insensitiv
(including pdo::null_natural,pdo::null_empty_string,pdo::null_to_ STRING) to specify the value that the null value returned by the database corresponds to in PHP.4. Pdo common method and its application
Pdo::query () is primarily used for operations that have logged results returned, especially the select operation
Pdo::exec () is primarily for operations returned without a result set, such as INSERT,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.