query-performance

Optimise comparing data in two big MySQL tables

南笙酒味 提交于 2020-01-16 08:40:09
问题 How could I optimise query, which will find all records, which: have activation_request.date_confirmed not null and do not have related string value in another table: activation_request.email = user.username shouldn't return any record I tried: SELECT email FROM activation_request l LEFT JOIN user r ON r.username = l.email WHERE l.date_confirmed is not null AND r.username IS NULL and SELECT email FROM activation_request WHERE date_confirmed is not null AND NOT EXISTS (SELECT 1 FROM user WHERE

MySQL index for normal column and full text column

时光总嘲笑我的痴心妄想 提交于 2020-01-15 09:48:09
问题 I'm trying to speed up a query for the below: My table has around 4 million records. EXPLAIN SELECT * FROM chrecords WHERE company_number = 'test' OR MATCH (company_name,registered_office_address_address_line_1,registered_office_address_address_line_2) AGAINST('test') LIMIT 0, 10; +------+-------------+-----------+------+------------------+------+---------+------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+---------

How to obtain the most recent row per type and perform calculations, depending on the row type?

一个人想着一个人 提交于 2020-01-13 16:29:52
问题 I need some help writing/optimizing a query to retrieve the latest version of each row by type and performing some calculations depending on the type. I think would be best if I illustrate it with an example. Given the following dataset: +-------+-------------------+---------------------+-------------+---------------------+--------+----------+ | id | event_type | event_timestamp | message_id | sent_at | status | rate | +-------+-------------------+---------------------+-------------+---------

Oracle optional bind variables

扶醉桌前 提交于 2020-01-06 08:04:15
问题 I have a query to select users from a table, given user id. This parameter is optional. This is the query: SELECT * FROM USERS WHERE (USER_ID = :USER_ID OR :USER_ID IS NULL) ORDER BY USER_ID; Now I execute the query finding one user, so :USER_ID takes the valor 1 : SELECT * FROM USERS WHERE (USER_ID = 1 OR 1 IS NULL) ORDER BY USER_ID; This query takes 5 seconds. And then, I add to the previous query OR :USER_ID IS NULL many times. This example takes much more time than the first: SELECT *

Querying Large Table in sql server 2008 [duplicate]

核能气质少年 提交于 2020-01-05 08:59:23
问题 This question already has answers here : Improve SQL Server query performance on large tables (9 answers) Closed 6 years ago . We have a table with 250 Million records (unique 15 digit number. Clustered Unique Index column) which will be queried at least by 0.7 to 0.9 Million requests on an average/day. We have multi applications accessing this table. Each application will try to compare 500,000 data against this 260 Million records. We have application that will add more data to this Large

PostgreSQL citext index vs lower expression index performance

*爱你&永不变心* 提交于 2020-01-04 05:19:07
问题 I want to decide between using a citext column with an index or using a text column with an index on lower() . I performed some benchmarks. To my surprise the search with the index on lower() causes an index scan, but in the citext case I get an index only scan. I was expecting the index on lower() to cause an index only scan too. Also, the total cost with the citext index is 4.44, but with the index on lower() , the total cost is 8.44. So the first thing coming to my mind is that the citext

Multiple optional query parameters with PostgreSQL

眉间皱痕 提交于 2020-01-03 05:45:08
问题 I use PostgreSQL10 and I want to built queries that have multiple optional parameters. A user must input area name, but then it is optional to pick none or any combination of the following event, event date, category, category date, style So a full query could be "all the banks (category), constructed in 1990 (category date) with modern architecture (style), that got renovated in 1992 (event and event date) in the area of NYC (area) ". My problem is that all those are in different tables,

Solr * vs *:* query performance

坚强是说给别人听的谎言 提交于 2020-01-03 03:16:18
问题 We're running Solr 3.4 and have a relatively small index of 90,000 documents or so. These documents are split over several logical sources, and so each search will have an applied filter query for a particular source, e.g: ?q=<query>&fq=source:<source> where source is a classic string field. We're using edismax and have a default search field text . We are currently seeing q=* taking on average 20 times longer to run than q=*:* . The difference is quite noticeable, with *:* taking 100ms and *

How to tell when a Postgres table was clustered and what indexes were used

陌路散爱 提交于 2020-01-02 05:23:06
问题 I've been impressed by the performance improvements achieved with clustering, but not with how long it takes. I know clustering needs to be rebuilt if a table or partition is changed after the clustering, but unless I've made a note of when I last clustered a table, how can I tell when I need to do it again? I can use this query to tell me what table(s) have one or more clustered indexes SELECT * FROM pg_class c JOIN pg_index i ON i.indrelid = c.oid WHERE relkind = 'r' AND relhasindex AND i

Performance of Delta E (CIE Lab) calculating and sorting in SQL

南楼画角 提交于 2019-12-31 17:12:16
问题 I have a database table where each row is a color. My goal: given an input color, calculate its distance to each color in the DB table, and sort the results by that distance. Or, stated as a user story: when I choose a color, I want to see a list of the colors that are most similar to the one that I picked, with the closest matches at the top of the list. I understand that, in order to do this, the various Delta E (CIE Lab) formulae are the best choice. I wasn't able to find any native SQL