explain

Explain plan in mysql performance using Using temporary; Using filesort ; Using index condition

雨燕双飞 提交于 2019-12-02 11:21:18
问题 I read various blogs and documents online but just wanted to know how i can optimize the query. I am unable to decide if we have to rewrite the query or add indexes in order to optimize. Adding create table structure also CREATE TABLE `dsr_table` ( `DSR_VIA` CHAR(3) DEFAULT NULL, `DSR_PULLDATA_FLAG` CHAR(1) DEFAULT 'O', `DSR_BILLING_FLAG` CHAR(1) DEFAULT 'O', `WH_FLAG` CHAR(1) DEFAULT 'O', `ARCHIVE_FLAG` CHAR(1) NOT NULL DEFAULT 'O', `DSR_BOOKING_TYPE` INT(2) DEFAULT NULL, `DSR_BRANCH_CODE`

MySQL slow query using filesort

落花浮王杯 提交于 2019-12-02 09:47:17
I have speed problems with a MySQL query. The tables definitions are as follows: CREATE TABLE IF NOT EXISTS `student` ( `student_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `forename` varchar(30) NOT NULL, `updated_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `surname` varchar(50) NOT NULL, `student_college` int(11) DEFAULT NULL, `countup` smallint(5) unsigned DEFAULT NULL, PRIMARY KEY (`student_id`), KEY `countup` (`countup`), KEY `student_sort` (`countup`,`updated_time`), KEY `student_college` (`student_college`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; and

Explain plan in mysql performance using Using temporary; Using filesort ; Using index condition

旧时模样 提交于 2019-12-02 07:19:52
I read various blogs and documents online but just wanted to know how i can optimize the query. I am unable to decide if we have to rewrite the query or add indexes in order to optimize. Adding create table structure also CREATE TABLE `dsr_table` ( `DSR_VIA` CHAR(3) DEFAULT NULL, `DSR_PULLDATA_FLAG` CHAR(1) DEFAULT 'O', `DSR_BILLING_FLAG` CHAR(1) DEFAULT 'O', `WH_FLAG` CHAR(1) DEFAULT 'O', `ARCHIVE_FLAG` CHAR(1) NOT NULL DEFAULT 'O', `DSR_BOOKING_TYPE` INT(2) DEFAULT NULL, `DSR_BRANCH_CODE` CHAR(3) NOT NULL, `DSR_CNNO` CHAR(12) NOT NULL, `DSR_BOOKED_BY` CHAR(1) NOT NULL, `DSR_CUST_CODE`

How to make Sqlite use an index for ordering on multiple columns in the case of multiple selection from the same table?

若如初见. 提交于 2019-12-01 14:43:09
I have a table with a few hundred thousand lines. (It’s a precomputed table expressing the relation between lemmas of words and other big tables.) I need to do multiple selections to find a combination of different entries, i.e. I have to use “AS” to do select … from ltc as l0, ltc as l1, ltc as l2 … order by ... The speed of the query depends on the sorting: Without sorting, it’s a few milliseconds, with sorting, it can take a few minutes. This is due, as far as I can tell, to the temporary B-Tree that Sqlite builds for sorting, even though I have an index on the sorted column “nr”. I don’t

Can JDBC statement run execution plan / explain plan?

拥有回忆 提交于 2019-12-01 14:32:00
Can JDBC statement run explain plan on query string? The code throws SQL exception Error message: Incorrect syntax near the keyword 'plan'. Stacktrace is null I just copy from internet of using stmt.execute. However, it seems that stmt.execute() only Returns true if the first result is a ResultSet object; false if it is an update count or there are no results conn = getEntityManager().unwrap(java.sql.Connection.class); stmt = conn.createStatement(); stmt.execute("explain plan for SELECT 1 from Dual"); // throws sql exception rs = stmt.executeQuery("select plan_table_output from table(dbms

Can JDBC statement run execution plan / explain plan?

戏子无情 提交于 2019-12-01 13:02:35
问题 Can JDBC statement run explain plan on query string? The code throws SQL exception Error message: Incorrect syntax near the keyword 'plan'. Stacktrace is null I just copy from internet of using stmt.execute. However, it seems that stmt.execute() only Returns true if the first result is a ResultSet object; false if it is an update count or there are no results conn = getEntityManager().unwrap(java.sql.Connection.class); stmt = conn.createStatement(); stmt.execute("explain plan for SELECT 1

SQL INDEX not used on WHERE ABS(x-y) < k condition, but used on y - k < x < y + k condition

混江龙づ霸主 提交于 2019-12-01 12:00:06
问题 I have a query involving couples of rows which have a less-than-2-hours time-difference (~0.08333 days): SELECT mt1.*, mt2.* FROM mytable mt1, mytable mt2 WHERE ABS(JULIANDAY(mt1.date) - JULIANDAY(mt2.date)) < 0.08333 This query is rather slow, i.e. ~ 1 second (the table has ~ 10k rows). An idea was to use an INDEX . Obviously CREATE INDEX id1 ON mytable(date) didn't improve anything, that's normal. Then I noticed that the magical query CREATE INDEX id2 ON mytable(JULIANDAY(date)) didn't help

mongodb keep_mutation stage explain

时光怂恿深爱的人放手 提交于 2019-12-01 06:54:14
问题 I use mongo's explain() to check the performance of some queries, sometimes a keep_mutation stage will show up like the following: "executionStats" : { ... "executionStages" : { "stage" : "KEEP_MUTATIONS", "nReturned" : 1, "executionTimeMillisEstimate" : 5460, "works" : 79622, ... } } I want to know more about this stage so I search through the internet, and to my surprise, I couldn't find useful info related to it even in the official document, let alone other websites. Could someone help to

Reuse computed select value

旧街凉风 提交于 2019-12-01 06:50:02
I'm trying to use ST_SnapToGrid and then GROUP BY the grid cells (x, y). Here is what I did first: SELECT COUNT(*) AS n, ST_X(ST_SnapToGrid(geom, 50)) AS x, ST_Y(ST_SnapToGrid(geom, 50)) AS y FROM points GROUP BY x, y I don't want to recompute ST_SnapToGrid for both x and y . So I changed it to use a sub-query: SELECT COUNT(*) AS n, ST_X(geom) AS x, ST_Y(geom) AS y FROM ( SELECT ST_SnapToGrid(geom, 50) AS geom FROM points ) AS tmp GROUP BY x, y But when I run EXPLAIN , both of these queries have the exact same execution plan: GroupAggregate (...) -> Sort (...) Sort Key: (st_x(st_snaptogrid

what is the equivalent of EXPLAIN form SQLite in SQL Server?

天涯浪子 提交于 2019-12-01 05:13:22
I used an SQLite database and run an EXPLAIN statement before executing the actual query to verify if there was any attempt to write on the database. Now, we have migrated to SQL Server and I need to know if a query tries to write on the database or is just a simple SELECT statement. I basically try to avoid any malicious statement. You can see the estimated query plan of any query in SSMS by clicking the estimated query plan button. See MSDN . However, if the user shouldn't be writing to the database, is shouldn't have the permissions to do so. Ensure it belongs to a role that has restricted