database-performance

Improve performance of first query

自闭症网瘾萝莉.ら 提交于 2019-12-05 08:12:36
If the following database (postgres) queries are executed, the second call is much faster. I guess the first query is slow since the operating system (linux) needs to get the data from disk. The second query benefits from caching at filesystem level and in postgres. Is there a way to optimize the database to get the results fast on the first call? First call (slow) foo3_bar_p@BAR-FOO3-Test:~$ psql foo3_bar_p=# explain analyze SELECT "foo3_beleg"."id", ... FROM "foo3_beleg" WHERE foo3_bar_p-# (("foo3_beleg"."id" IN (SELECT beleg_id FROM foo3_text where foo3_bar_p(# content @@ 'footown'::tsquery

Tune Oracle Database for faster startup (flashback)

我的梦境 提交于 2019-12-05 08:05:26
I'm using Oracle Database 11.2. I have a scenario where I issue FLASHBACK DATABASE quite often. It seems that a FLASHBACK DATABASE cycle does a reboot of the database instance which takes approx. 7 seconds on my setup. Database is small (~ 1 GB tablespace), all files should be in I/O caches/buffers. Therefore I think that the bottleneck is not I/O based. I'm looking for tuning advices in order to save user time and/or CPU time for doing a flashback. UPDATE: Flashback sequence (and timing of each step) is the following: 1. Get SYSDBA connection with prelim_auth=true [15 ms] 2. SHUTDOWN ABORT;

MYSQL Huge SQL Files Insertion | MyISAM speed suddenly slow down for Insertions (strange issue)

孤者浪人 提交于 2019-12-05 07:35:23
问题 I'm facing very strange problem, I've asked the question here about speed up the insertion in MYSql, especially about the insertion of Huge SQL files multiple GB in size. They suggested me to use MyISAM engine. I did the following: ALTER TABLE revision ENGINE=MyISAM; Use ALTER TABLE .. DISABLE KEYS . (MyISAM only) Set bulk_insert_buffer_size to 500M. (MyISAM only) Set unique_checks = 0 . not checked. SET autocommit=0; ... SQL import statements ... COMMIT; SET foreign_key_checks=0; It Speed up

Performance when using batch mode of Qt / MySQL

杀马特。学长 韩版系。学妹 提交于 2019-12-04 20:53:53
问题 I am using the SQL module of Qt 5.3.1 (Win 7, VS2013) to insert data into a MySQL 5.6 database. After I noticed some performance issues I execute three test code snippets and measured their runtime to get a better understanding of SQL performance. The result is confusing. For testing I used a "test" table containg a VARCHAR column "test" and a uniquely incremented id for each row. The first snippet looks essentially like this: const QString uploadQueryString("INSERT INTO test (test) VALUES ('

I've hit the DB performance bottleneck, where now?

怎甘沉沦 提交于 2019-12-04 19:57:02
问题 I have some queries that are taking too long (300ms) now that the DB has grown to a few million records. Luckily for me the queries don't need to look at the majority of this data, that latest 100,000 records will be sufficient so my plan is to maintain a separate table with the most recent 100,000 records and run the queries against this. If anyone has any suggestions for a better way of doing this that would be great. My real question is what are the options if the queries did need to run

Slow running Postgres query

人走茶凉 提交于 2019-12-04 19:43:41
I have this query that takes a very long time on my database. This SQL is generated from an ORM (Hibernate) inside of an application. I don't have access to the source code. I was wondering if anyone can take a look at the following ANALYZE EXPLAIN output and suggest any Postgres tweaks I can make. I don't know where to start or how to tune my database to service this query. The query looks like this select resourceta0_.RES_ID as col_0_0_ from HFJ_RESOURCE resourceta0_ left outer join HFJ_RES_LINK myresource1_ on resourceta0_.RES_ID = myresource1_.TARGET_RESOURCE_ID left outer join HFJ_SPIDX

Is AsList() better than ToList() with IDbConnection.Query() which returns IEnumerable?

主宰稳场 提交于 2019-12-04 18:27:19
问题 I read this answer from Marc Gravell (@MarcGravell): https://stackoverflow.com/a/47790712/5779732 The last line says: As a minor optimization to your code: prefer AsList() to ToList() to avoid creating a copy. That statement is about QueryMultiple() which returns GridReader . In my understanding, System.Linq provides an extension method IEnumerable.ToList() . Following is from Microsoft about ToList() . The ToList(IEnumerable) method forces immediate query evaluation and returns a List that

Improving performance of spatial MySQL query

谁都会走 提交于 2019-12-04 17:55:13
I have a query that returns all records, ordered by distance from a fixed point, compared to a POINT field in my MySQL 5.7 database. For a simple example, lets say it looks like this: SELECT shops.*, st_distance(location, POINT(:lat, :lng)) as distanceRaw FROM shops ORDER BY distanceRaw LIMIT 50 My actual query also has to do a few joins to get additional data for the results. The issue is, that in order to sort the data by distance, it needs to calculate the distance over every single record in the database (currently around 100,000 records). I can't cache the query, as it would only be

Is there any benefit to creating and index on a primary key?

蹲街弑〆低调 提交于 2019-12-04 14:50:27
I checked this SO post: What's the difference between primary key, unique key, and index in MySQL? and found the statement: Also note that columns defined as primary keys or unique keys are automatically indexed in MySQL. Based on this, I have two questions: Am I safe in assuming that there is no performance benefit to creating an index on a primary key itself because the primary key, by design, is an index? Perhaps the more important question: If you are doing the classic example people cite, doing SELECT based on lastName and firstName, and that table has a primary key that you SELECT by

Why is using an INT to select a Varchar index containing numbers much slower than using Strings?

早过忘川 提交于 2019-12-04 11:07:54
I have a table that contains several thousand rows, having a Varchar column that contains numbers. Despite discussing why this column is not a numeric type then, selecting rows from that table showed a strange behavior. Although there is an index on that column, using numeric strings to find a row is MUCH faster (0.01 secs) than using Ints (0.54 secs). What is the reason for this? It seems not to be able to cast and use the value for the index... Am I overlooking something? It looks like it is not casting the Int to use it for the index? Do I have to give hints on index usage, or is there a