Encounter a hole: for the following codeSelect * from where > ' 2015-11-1 ' and date'2015-11-5'Results can be obtained when executed in the client of PostgreSQL, but when executed in Java (the time range is a parameter, type string), such as Date gt;=#{startday} and date The execution times are as follows: (and for MySQL, it can be executed correctly in code.) ) not timestamp > character varyingWORKAROUND: Change the parameter of type string to Java
Yesterday's SQL Server query performance optimization-index creation principle (I) mainly introduced the principle. today are some of the main principles and checks the created indexes.
Iii. indexing principles
In general, building indexes depends on the data usage scenarios. In other words, which SQL statements are commonly used to access data? Are these statements missing indexes (or there may be too many
Golang Custom Data Type query and insertion of point data in postgresqlGolang Custom Data Type query and insertion of point data in postgresql
The Code is as follows:
Package mainimport ("bytes" "database/SQL" "database/SQL/driver" "fmt" _ "github.com/lib/pq" "strconv" "strings ") // custom supported types: type Point struct {X float64 'json: "lat" 'Y float64' js
,neibuyonghu,reader,title from Tgongwen where fariqi> ' 2004-1-1 ' and fariqi4. The date column will not slow down the query speed because there is a minute or seconds inputIn the following example, there are 1 million data, 500,000 data after January 1, 2004, but only two different dates, the date is accurate to the day, before the data 500,000, there are 5,000 different dates, the date is accurate to the second.Select Gid,fariqi,neibuyonghu,reader,t
-----------+---------------------------------------------------------------------------------------------------------------+-------------------------------+---------+---------------- gpcluster | DELETE FROM TABLE_NAME WHERE A = 1 | 2011-05-14 09:35:47.721173+08 | 17509 | 192.168.165.18(1 row)
Through the above, we can find that the above Lock keeps the statement hanging there. After the lock is completed, the application will soon run out.
Then, check the application code and find that
Query statements for all table structures in the PostgreSQL Column
SELECT tablename FROM pg_tablesWHERE tablename not like 'pg %'AND tablename not like 'SQL _ %'Order by tablename;
Query the field information of the t_appointment_apply table.SELECT a. attnum, a. attname AS field, t. typname AS type, a. attlen AS length,. Atttypmod AS lengthvar,. attnotnull AS n
EFFECTIVE_CACHE_SIZE128MB optimizer assumes that a query can use the maximum memory, and shared_buffers regardless (1/2 of the recommended memory) is set slightly larger and the optimizer prefers to use index scans instead of sequential scansMAINTENANCE_WORK_MEM16MB the memory defined here is only used when a more resource-intensive command call is made, such as vacuum, to increase the value, and to speed up the execution of the command.WAL_BUFFER768
matches m atoms
{m,}
A sequence that matches m or more atoms
{m,n}
A sequence of atoms that matches m to N (containing two ends);m cannot be larger than n
*?
* non-greedy mode
+?
+ non-greedy mode
??
? The non-greedy mode
{m}?
Non-greedy mode for {m}
{m,}?
Non-greedy mode for {m,}
{m,n}?
Non-greedy mode for {m,n}
{... The for
Record Data Query Optimization and Data Query Optimization
One day, the bricks were moving so hot that a call was suddenly called. The business department reflected that a function was very slow and it was simply unbearable. How slow is it? About 90 s. Is it suddenly slow? Or was it slow before? It was a little slow be
PostgreSQL provides a powerful regular expression system that enables fuzzy queries at the database level.Regular expression matching operators:
operator
Description
Example
~
Match regular expressions, case-related
' Thomas ' ~ '. *thomas.* '
~*
Match regular expression, case-insensitive
' Thomas ' ~* '. *thomas.* '
!~
Mismatched regular expressio
.
(4) processing instead of ROW UPDATE Triggers. If present, call the Execirupdatetriggers function to process and return directly without an insert operation.
(5) Processing foreign table, for which the ri_fdwroutine is initialized. Call the foreign server's API to process the update for that tuple and get the returned slot.
(6) Handle the condition (execwithcheckoptions function) and uniqueness constraint (execconstraints function) on OnConflict option in with CHECK option.
(7)
Tags: order experience various types of linked list resource management share picture ODI context resource allocation2. Can optimize the execution of the statementThe common feature of the optimized statements is that they are processed by the query compiler to generate an inquiry plan tree, which is handled by the executor (Executor). The module provides three interfaces externally: Executorstart, Executorrun, and Executorend, whose input is the data
After using gin () to create a full-text index, the query is still very efficient when the result set is large, although there is a walk index.Update_time is not null and plainto_tsquery (' driver ') @@ keyword_participle ORDER by Avg_mon_search DESC LIMIT OFFSET 0;Background: The keyword table has 80 million rows of data, a gin (keyword_participle) index is established, and the BTREE index of the other sort fieldsAnalysis: When the
deptno, avg (SAL) from EMP
WHERE Deptno in (a) GROUP by
Deptno;
Efficiency will be higher than the following
SELECT deptno, avg (SAL) from EMP
WHERE Deptno in (a) GROUP by
Deptno;
Of course, if the filter conditions of a grouped query design group calculations, they can only be specified in the HAVING clause.
5. Sub-query optimization
Tags: sel div weight span subquery query lag around 11gEnvironment: Oracle 11g The existing A and B tables are associated with the A01 field, and the data in table A is not available in B. SQL as follows Select Count (1 from (select A.*, (selectCount(1) from where b.a01=as fromwhere flag=0 Because flag is a virtual field, the index causes the SQL to execute particularly slowly, and the total number of 310W data is about 2 seconds. Use NOT exists t
there are usually several ways to tune a database:
1) Manual tuning.
The
main reliance on people, inefficient, requiring the operator to fully understand the principle of common sense depends on, but also the application, database management system, operating system and hardware have a broad and deep understanding.
2) Case-based tuning .
This
paper summarizes the recommended configuration values of database parameters and the design of
MySQL query optimization and MySQL Optimization1. Introduction
A good web application has excellent access performance. MySQL database is an integral part of web applications and an important part that determines their performance. Therefore, it is vital to improve MySQL performance.
MySQL performance improvement can be divided into three parts, including hardware, network, and software. The hardware and ne
Sort out the key points of Data Query Optimization in Oracle databases, and query oracle Data
The most basic task of a database is to store and manage data. The only database feature that an end user can see is its performance: the speed at which the database processes the results of a specified query, and return the r
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.