query processor.
For example, suppose you want to find the customer IDs of a series of orders by order ID. You can perform this operation in two ways. The first method is to perform the following steps for each search:
Open orders base table
Use a specific "Order ID" to find rows
Retrieve "Customer ID"
Alternatively, the following
statement,execution in Query Analyzer------------------------------------------------------------------------several issues used by log Explorer----------------------------------------------------------------------1) Make a full/differential databaseLog Backup Backup If you choose to delete the inactive entries in the transaction log and then use Log Explorer to try to read the log, you are prompted no log recorders found that match the filter,would
It is understood that most developers have a smattering of understanding of the index, limited to most of the daily work no opportunity, what is not necessary to care about, understand the index, it is really a query too slow to find the query conditions to build an index on OK, which day again a query slow, and then e
. dynamic queryWith the features of PHP5, ThinkPHP enables dynamic queries.
1. getBy dynamic query
// Find the data for email = xiaoin@163.com
$ User = M ('user ');
Var_dump ($ user-> getByemail ('xiaoxin @ 163.com '));
2. getFieldBy dynamic query
// Get the corresponding id value through user
$ User = M ('user ');
Var_dump ($ user-> getFieldByUser ('lufei ', 'id
Tags: Begin query cannot exp ALT COM Style Topic str There is a classic title: 1-100 of the number (not repeating) stored in the table, a total of 95 rows of a column, but there is missing 5 numbers, how to use SQL to find the fastest five numbers. Let's take a look at how the Oracle database is implemented, as shown below, and we'll prepare the test environment
of LINQ is that it makes it very easy to see exactly what SQL code is actually executing. From the BETA2 version of Visual Studio 2008, you can use the new Plug-in program LINQ to SQL Viewer to easily view (and test) any LINQ to SQL query expressions. Simply set a breakpoint on a LINQ to
table is frequently updated operation, and whether the data to be read back will be modified, so the measurement whether to use with (NoLock) or based on the actual reality.Optimizing indexesAre there any missing or redundant indexes? Do you have any duplicate indexes?Handling deadlocksWe cannot observe the deadlock all the time, but we can record the deadlock of the system through the log, we can write the deadlock error of the system to the table, so it is convenient to analyze the cause of d
If your experience in SQL is not rich enough and you have not solved many problems in SQL, read this chapter carefully, it helps you avoid a mistake that is likely to be made frequently!
Create a test table first.
Create Table # Table1 (ID int identity (1, 1) primary key, col1 int not null, col2 decimal (18, 1 ))
Insert data
Insert into # Table1 (col1, col2) Select 0, 0.1 Union all select 1, 1.1 Uni
In SQL ServerEach database has a table generated by the system.The table sysobjects records all the table names in the database.We can use the following SQL syntax for query operations.
Copy codeThe Code is as follows:Select Name, id from sysobjects where xtype = 'U'
Xtype = 'U' indicates the table used. If xtype = 's' is used'The default table
There is also a
statement 5.2 Multi-row subqueries Sql>select Ename,job,sal,deptno from EMP where job in (SELECT DISTINCT job from EMP where deptno=10), query table with the same staff with department Number 10 The name, work, salary, department number of the worker. Because there are multiple rows in the returned result, the subquery is concatenated with "in". In and exists: exists () the subquery that follows is called
--
Script used to obtain the connection information of the SQL Server server (based on the original shard creation and writing)
Declare@ Dbname sysname,-- The name of the database to be queried (empty for all). The connection information of all databases is queried by default.@ Brief deip bit-- Whether to display the IP address (0 NO, 1 Yes). This control is added because the IP address query is time-consu
Label:The set operator is operated on two sets, two sets must have the same number of columns, the column has the same data type (at least implicitly convertible), and the final output of the collection's column name is determined by the column name of the first collection (which can be used to concatenate multiple results). Note: Union "union" is not the same as join. Union: Combines multiple result sets into a single result set. Union (removes duplicates
our SalesOrderHeader and contact information to join 5 . Figure 5- plan to have a connection query that supports indexes on each table since the input stream is now connected by a predicate, ContactID , the query of the part of the sequencing can be done without splitting the stream without hashing, thus reducing + 5 + 3 = 34% under the workload 4% what the workload is. Sorting, presorting and Hashing
unlocked not locked updates * Specifying the NOLOCK hint will make the table with the hint specified in cursor read-only. 16, use Profiler to track the query, get the time required to query, find out the problem of SQL; optimizing indexes with the index optimizer17, pay attention to the difference between union and Un
Multi-row subqueries Sql>select Ename,job,sal,deptno from EMP where job in (SELECT DISTINCT job from EMP where deptno=10), query table with the same staff with department Number 10 The name, work, salary, department number of the worker. Because there are multiple rows in the returned result, the subquery is concatenated with "in". In and exists: exists () the subquery that follows is called the correlated
locked NOLOCK unlocked unlocked unlocked HOLDLOCK shared share share update UPDLOCK error update update TABLOCKX error unlocked unlocked Fixed update other unlocked unlocked Unlocked update * Specifies that the NOLOCK hint will make the table specified with this hint read-only in cursor.16. Use Profiler to track queries, get the time needed to query, find out the problem of
Analyze the 48 causes of slow SQL query.
Analyze the 48 causes of slow SQL query.
There are many reasons for slow query speed. The following are common causes:
1. No index or no index is used (this is the most common problem of slow que
Myth 1. An index is established on a table and an indexed column is used at query time, and the index is bound to take effectFirst of all, it is wrong to make it clear that the SQL Server query optimizer is a cost-based optimizer that determines whether to use an index, what type of index to use, and which index to use, through a series of complex judgments.
1, first to understand what is called the implementation plan?An execution plan is a query scheme that the database makes based on the statistics of SQL statements and related tables, which are generated automatically by the query optimizer, such as an SQL statement that searches for 1 records from a 100,000-record tab
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.