query-performance

MySQL Embedded SELECTs vs. JOINs

自古美人都是妖i 提交于 2019-12-10 17:36:27
问题 Is there a noticeable difference between: SELECT userid, username, userdept, (SELECT deptname FROM depts WHERE deptid=userdept) AS deptname FROM users and SELECT userid, username FROM users INNER JOIN depts ON depts.deptid=users.userdept Which one is better? 回答1: Your second query has better performance. You can see this example: http://www.codersrevolution.com/index.cfm/2008/7/31/MySQL-performance-INNER-JOIN-vs-subselect 回答2: join is better , see this link : http://www.selikoff.net/2008/12

MySQL: Why 5th ID in the IN clause drastically changes query plan?

白昼怎懂夜的黑 提交于 2019-12-10 14:56:33
问题 Given the following two queries: Query #1 SELECT log.id FROM log WHERE user_id IN (188858, 188886, 189854, 203623, 204072) and type in (14, 15, 17) ORDER BY log.id DESC LIMIT 25 OFFSET 0; Query #2 - 4 IDs instead 5 SELECT log.id FROM log WHERE user_id IN (188858, 188886, 189854, 203623) and type in (14, 15, 17) ORDER BY log.id DESC LIMIT 25 OFFSET 0; Explain Plan -- Query #1 1 SIMPLE log range idx_user_id_and_log_id idx_user_id_and_log_id 4 41280 Using index condition; Using where; Using

No execution plan caching for dynamic SQL in PostgreSQL 9.4?

依然范特西╮ 提交于 2019-12-10 11:49:15
问题 This is just a prospective question, at work we're thinking of moving from SQL Server to PostgreSQL, please tell me I didn't understand this correctly from the PostgreSQL 9.4 documentation: "There is no plan caching for commands executed via EXECUTE". We have a critical SP that builds a dynamic query and executes it, initially I didn't build the dynamic SQL correctly (the dynamic query was not parameterized) and because of that each time when this SP was hit, it spend ~ 1500ms to recompile

Is there a proven performance difference between joins in Hive on INT/BIGINT versus VARCHAR?

徘徊边缘 提交于 2019-12-08 17:38:27
问题 For years I have been reading / hearing about the 'performance advantage' of database joins on bigint columns have OVER joins on (var)char columns. Unfortunately, when looking for real answers / advice regarding to 'simlilar type questions' : The examples used are in a 'traditional' RDBMS context, like Mysql or Oracle / SQL Server. Take for instance this question or this example The answer is quite old and the end-difference in runtime is not that great. Again, see this example I have not

Query very slow. The issue is “ read by other session” due to union ALL

非 Y 不嫁゛ 提交于 2019-12-08 11:33:24
问题 I have below query. the below query has union all twice. Due to this ,query is waiting for the same resource and wait time is too high. Below is the output of sql trace. Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ SQL*Net message to client 1 0.00 0.00 Disk file operations I/O 1047 0.00 0.15 db file sequential read 167048 0.64 1584.33 db file parallel read 216 0.05 1.37

Alter session slows down the query through Hibernate

99封情书 提交于 2019-12-08 09:00:11
问题 I'm using Oracle 11gR2 and Hibernate 4.2.1. My application is a searching application. Only has SELECT operations and all of them are native queries. Oracle uses case-sensitive sort by default. I want to override it to case-insensitive. I saw couple of option here http://docs.oracle.com/cd/A81042_01/DOC/server.816/a76966/ch2.htm#91066 Now I'm using this query before any search executes. ALTER SESSION SET NLS_SORT='BINARY_CI' If I execute above sql before execute the search query, hibernate

MySQL Query taking over 6 seconds

坚强是说给别人听的谎言 提交于 2019-12-08 04:42:39
问题 Awhile back I got some help with a specific query. Here's the link: SQL Group BY using strings in new columns My query looks similar to this: SELECT event_data, class_40_winner, class_30_winner FROM events e LEFT JOIN (SELECT result_event, name AS class_40_winner FROM results WHERE class = 40 AND position = 1) c40 ON e.id = c40.result_event LEFT JOIN (SELECT result_event, name AS class_30_winner FROM results WHERE class = 30 AND position = 1) c30 ON e.id = c30.result_event I have now entered

How to measure RU in DocumentDB?

久未见 提交于 2019-12-08 04:36:16
问题 Given that Azure DocumentDB uses Requests Units as a measurement for throughput I would like to make sure my queries utilize the least amount of RUs as possible to ncrease my throughput. Is there a tool that will tell me how many RUs a query will take and if the query is actually using an index or not? 回答1: As you discovered, certain tools will provide RU's upon completion of a query. This is also available programmatically, as the x-ms-request-charge header is returned in the response, and

SQL Performance: Using OR is slower than IN when using order by

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 22:46:36
问题 I am using MariaDB 10.0.21 and running a query similar to the following query against 12 Million Rows: SELECT `primary_key` FROM `texas_parcels` WHERE `zip_code` IN ('28461', '48227', '60411', '65802', '75215', '75440', '75773', '75783', '76501', '76502', '76504', '76511', '76513', '76518', '76519', '76520', '76522', '76525', '76527', '76528', '76530', '76537', '76539', '76541', '76542', '76543', '76548', '76549', '76550', '76556', '76567', '76571', '76574', '76577', '76578', '76642', '76704'

Optimize MySQL Full outer join for massive amount of data

ⅰ亾dé卋堺 提交于 2019-12-07 13:21:18
问题 We have the following mysql tables (simplified for going straight to the point) CREATE TABLE `MONTH_RAW_EVENTS` ( `idEvent` int(11) unsigned NOT NULL, `city` varchar(45) NOT NULL, `country` varchar(45) NOT NULL, `ts` datetime NOT NULL, `idClient` varchar(45) NOT NULL, `event_category` varchar(45) NOT NULL, ... bunch of other fields PRIMARY KEY (`idEvent`), KEY `idx_city` (`city`), KEY `idx_country` (`country`), KEY `idClient` (`idClient`), ) ENGINE=InnoDB; CREATE TABLE `compilation_table` (