database-performance

MySQL fetch time optimization

时光毁灭记忆、已成空白 提交于 2019-12-03 14:23:40
oI have a table with 2 millions of registers, but it will grow much more soon. Basically this table contains points of interest of an image with respective descriptors. When I'm trying to execute query that selects points that are spatially near to the query points, total execution time takes too long. More precisely Duration / Fetch = 0.484 sec / 27.441 sec. And the query is quite simple, which returns only ~17000 rows. My query is: SELECT fp.fingerprint_id, fp.coord_x, fp.coord_y, fp.angle, fp.desc1, fp.desc2, fp.desc3, fp.desc4, fp.desc5, fp.desc6, fp.desc7, fp.desc8, fp.desc9, fp.desc10,

Performance when using batch mode of Qt / MySQL

我怕爱的太早我们不能终老 提交于 2019-12-03 13:34:51
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 ('%1')"); for (int i=0; i<1000; i++) { QSqlQuery uploadQuery(uploadQueryString.arg("A: test text"),

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

我与影子孤独终老i 提交于 2019-12-03 12:49:39
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 contains the query results. You can append this method to your query in order to obtain a cached copy of

Why is Oracle ignoring index with ORDER BY?

▼魔方 西西 提交于 2019-12-03 11:53:27
问题 My intention is to obtain a paginated resultset of customers. I am using this algorithm, from Tom: select * from ( select /*+ FIRST_ROWS(20) */ FIRST_NAME, ROW_NUMBER() over (order by FIRST_NAME) RN from CUSTOMER C ) where RN between 1 and 20 order by RN; I also have an index defined on the column "CUSTOMER"."FIRST_NAME": CREATE INDEX CUSTOMER_FIRST_NAME_TEST ON CUSTOMER (FIRST_NAME ASC); The query returns the expected resultset, but from the explain plan I notice that the index is not used:

Entity Framework is slow because of derived tables

送分小仙女□ 提交于 2019-12-03 09:36:57
问题 I am using MySQL Connector/Net 6.5.4 with LINQ to entities, and I frequently get terrible query performance because the entity framework generates queries that use derived tables. Here is a simplified example of what I've encountered several times. In C#, I write a query like this: var culverCustomers = from cs in db.CustomerSummaries where cs.Street == "Culver" select cs; // later... var sortedCustomers = culverCustomers.OrderBy(cs => cs.Name).ToList(); Instead of generating simple a query

surrogate vs natural key: hard numbers on performance differences?

扶醉桌前 提交于 2019-12-03 07:45:56
问题 There's a healthy debate out there between surrogate and natural keys: SO Post 1 SO Post 2 My opinion, which seems to be in line with the majority (it's a slim majority), is that you should use surrogate keys unless a natural key is completely obvious and guaranteed not to change. Then you should enforce uniqueness on the natural key. Which means surrogate keys almost all of the time. Example of the two approaches, starting with a Company table: 1: Surrogate key: Table has an ID field which

Cursors on MySQL - Good or Bad

送分小仙女□ 提交于 2019-12-03 04:23:42
I have always heard people saying bad about using cursors and this is especially in Microsoft SQL Server as they are very slow. Is this the case with Cursors on MySQL as well? Does cursors in MySQL reduce performance as well? Can someone please advice on the usage of cursors in MySQL? Most modern databases (including MySQL) are designed to perform set based operations. The problem with cursors is that they perform row based (or procedural) operations. Because of this you will almost always see a performance hits when you are using cursors to do a job that can be done without cursors on a

Strategies for fast searches of billions of small documents in MongoDB

末鹿安然 提交于 2019-12-03 03:12:12
问题 I need to store several billion small data structures (around 200 bytes each). So far, storing each element as a separate document is working well, with Mongo providing around 10,000 results per second. I'm using a 20-byte hash as the _id for each document, and a single index on the _id field. In testing, this is working for data sets with 5,000,000 documents. In operation, we will be making around 10,000 requests per second, updating existing documents about 1,000 times per second, and

Database partitioning - Horizontal vs Vertical - Difference between Normalization and Row Splitting?

纵然是瞬间 提交于 2019-12-03 01:10:35
问题 I am trying to grasp the different concepts of Database Partitioning and this is what I understood of it: Horizontal Partitioning/Sharding : Splitting a table into different table that will contain a subset of the rows that were in the initial table (an example that I have seen a lot if splitting a Users table by Continent, like a sub table for North America, another one for Europe, etc...). Each partition being in a different physical location (understand 'machine'). As I understood it,

What does exec sp_updatestats do?

佐手、 提交于 2019-12-03 01:09:24
What is the use of sp_updatestats ? Can I run that in the production environment for performance improvement? dean sp_updatestats updates all statistics for all tables in the database, where even a single row has changed. It does it using the default sample, meaning it doesn't scan all rows in the table so it will likely produce less accurate statistics than the alternatives. If you have a maintenance plan with 'rebuild indexes' included, it will also refresh statistics, but more accurate because it scans all rows. No need to rebuild stats after rebuilding indexes. Manually updating particular