query-optimization Questions

3

Solved

Consider and Employee and Address relationship. There is a One-to-one mapping between Employee and Address. Following are models: @Entity @Table(name = "Address") public class Address { @Id @Gen...
Moynahan asked 18/2, 2014 at 11:30

5

I have a table 'MSATTRIBUTE' with 3000K rows. I used the following query to retrieve data, this query has different execution plan with same DB data but in different env. in one env, it appears ful...

6

I wanted to migrate from BigQuery to CloudSQL to save cost. My problem is that CloudSQL with PostgreSQL is very very slow compare to BigQuery. A query that takes 1.5 seconds in BigQuery takes almos...
Nurserymaid asked 10/11, 2021 at 22:49

2

This is a FastAPI project using SQLAlchemy and an AWS RDS postgres database. The waits (AAS) on database suddenly increase above 2 (for a 2 vCPU - t4g.small instance), and when checking on Performa...
Conjunctive asked 5/10, 2023 at 14:15

4

Solved

The Setup What I am about to describe is run on the following hardware: Disk: 6x 2TB HDD in RAID5 (w/ 1 redundant drive) CPU: Intel Xeon E5-2640 @ 2.4 GHz, 6 Cores RAM: 64 GB SQL Server Version: S...
Arlenaarlene asked 18/12, 2020 at 11:10

6

Solved

I am trying to figure out the very best way, (probably doesn't matter in this case) to find the rows of one table, based on the existence of a flag, and an relational id in a row in another table. ...
Footslog asked 28/6, 2013 at 22:16

1

I have a windows service developed in .net / c#. It frequently updates a table with location data stored in SQL server. The update SQL query is etremely slow, somwehere between 0.5-1.5 sec. In this...
Sluggard asked 19/9, 2022 at 9:37

4

Solved

Is there any performance benefit in adding a LIMIT to an EXISTS query, or would MySQL apply the limit on its own? Example: IF EXISTS ( SELECT 1 FROM my_table LIMIT 1 -- can this improve perfor...
Vitalize asked 13/1, 2016 at 5:41

6

I have a SQL like this: INSERT INTO table1 (column1, column2) ( SELECT column3, column4 FROM table2 WHERE column5 = 'value' ); The table1 has 3,500,000 rows. The table2 has 900,000 rows. SELECT ...
Herzberg asked 7/6, 2021 at 23:34

5

Solved

My queries get very slow when I add a limit 1. I have a table object_values with timestamped values for objects: timestamp | objectID | value -------------------------------- 2014-01-27| 234 | ...
Laurenelaurens asked 27/1, 2014 at 16:1

6

Solved

I have a table I'm doing an ORDER BY on before a LIMIT and OFFSET in order to paginate. Adding an index on the ORDER BY column makes a massive difference to performance (when used in combination w...
Zurkow asked 7/7, 2011 at 23:36

10

Solved

I'm dealing with a Postgres table (called "lives") that contains records with columns for time_stamp, usr_id, transaction_id, and lives_remaining. I need a query that will give me the most recent l...
Ebersole asked 25/2, 2009 at 16:37

2

Solved

I have a database with several fields : word_id — INTEGER PRIMARY_KEY word — TEXT ... And ~150k rows. Since this is a dictionary, I'm searching for a word with mask 'search_string%' using LIKE. It...
Bazluke asked 21/12, 2011 at 2:41

20

Solved

Is there a better way of doing a query like this: SELECT COUNT(*) FROM (SELECT DISTINCT DocumentId, DocumentSessionId FROM DocumentOutputItems) AS internalQuery I need to count the number of d...
Streptothricin asked 24/9, 2009 at 12:3

3

I trying to improve search similar images pHashed in MySQL database. Right now I comparing pHash counting hamming distance like this: SELECT * FROM images WHERE BIT_COUNT(hash ^ 202835905253510827...
Underpin asked 17/2, 2013 at 19:30

3

Solved

I have a database using the following schema: CREATE TABLE IF NOT EXISTS `sessions` ( `starttime` datetime NOT NULL, `ip` varchar(15) NOT NULL default '', `country_name` varchar(45) default '',...
Oversleep asked 2/9, 2018 at 14:8

3

Solved

I've been reading up on this and I understand that it's better to explicitly list the column names, I still have a question. Let's pretend the following scenario (which is very close to my real lif...

2

Solved

Besides having mariadb 10.1.36-MariaDB I get following error. EXPLAIN ANALYZE select 1 MySQL said: Documentation 1064 - You have an error in your SQL syntax; check the manual that corresponds to ...
Jannette asked 22/3, 2020 at 9:44

8

I have a 400 line sql query which is throwing exception withing 30 seconds ORA-03113: end-of-file on communication channel Below are things to note: I have set the timeout as 10 mins There ...
Ratio asked 28/7, 2010 at 7:1

3

Solved

I want to select records from '2013-04-01 00:00:00' to 'today' but, each day has lot of value, because they are saving each 15 minutes a value, so I want only the first or last value from each day....
Slut asked 10/5, 2013 at 10:28

1

Solved

I would like to speed up the queries on my big table that contains lots of old data. I have a table named post that has the date column created_at. The table has over ~31 million rows and ~30 milli...

17

Solved

I recently found and fixed a bug in a site I was working on that resulted in millions of duplicate rows of data in a table that will be quite large even without them (still in the millions). I can ...
Bialy asked 23/8, 2009 at 16:39

3

Solved

From time to time I encounter a strange MySQL behavior. Let's assume I have indexes (type, rel, created), (type), (rel). The best choice for a query like this one: SELECT id FROM tbl WHERE rel = 3...
Biramous asked 24/12, 2010 at 13:52

4

Solved

I want to use a single query to update many records in my Postgres database using a Ruby hash or array, rather than having to iterate through each record and call a separate update. # {:id => :...

2

Solved

if it's known that there are only two values to candidate for the result of a column, ifnull(a, b) as a_or_b_1 and coalesce(a, b) as a_or_b_2 will give the same result. but which is faster? w...
Electricity asked 20/1, 2011 at 13:46

© 2022 - 2025 — McMap. All rights reserved.