database-performance

In MySQL, how to build index to speed up this query?

旧时模样 提交于 2019-11-28 19:56:21
In MySQL, how to build index to speed up this query? SELECT c1, c2 FROM t WHERE c3='foobar'; To really give a answer it would be useful to see if you have existing indexes already, but... All this is assuming table 't' exists and you need to add an index and you only currently have a single index on your primary key or no indexes at all. A covering index for the query will give best performance for your needs, but with any index you sacrifice some insertion speed. How much that sacrifice matters depends on your application's profile. If you read mostly from the table it won't matter much. If

Hibernate Criterion IN Clause 1000 break up

不打扰是莪最后的温柔 提交于 2019-11-28 19:42:29
Hi i have this large oracle hibernate web applications and it seems to give this error ORA-01795: maximum number of expressions in a list is 1000 and i need a java code tested by someone as a hibernate user defined component to add to my search java classes in my screen as easy as possible could someone have such tested component? shareef i tried this below code from link and it seem to work beautifully i will paste the code in-case the link were broken in future. Keep it Simple Keep it Smile :) /** * An utility method to build the Criterion Query IN clause if the number of parameter * values

Entity Framework Vs Stored Procedures - Performance Measure

安稳与你 提交于 2019-11-28 16:03:59
I'm trying to establish how much slower Entity Framework is over Stored Procedures. I hope to convince my boss to let us use Entity Framework for ease of development. Problem is I ran a performance test and it looks like EF is about 7 times slower than Stored Procs. I find this extremely hard to believe, and I'm wondering if I'm missing something. Is this a conclusive Test? Is there anything I can do to increase the performance of the EF Test? var queries = 10000; // Stored Proc Test Stopwatch spStopwatch = new Stopwatch(); spStopwatch.Start(); for (int i = 0; i < queries; i++ ) { using (var

MySQL Partitioning / Sharding / Splitting - which way to go?

耗尽温柔 提交于 2019-11-28 14:37:00
问题 We have an InnoDB database that is about 70 GB and we expect it to grow to several hundred GB in the next 2 to 3 years. About 60 % of the data belong to a single table. Currently the database is working quite well as we have a server with 64 GB of RAM, so almost the whole database fits into memory, but we’re concerned about the future when the amount of data will be considerably larger. Right now we’re considering some way of splitting up the tables (especially the one that accounts for the

Rails: How to split write/read query across master/slave database

橙三吉。 提交于 2019-11-28 12:15:31
My website has a very heavy read traffic. A lot heavier than write traffic. To improve the performance of my website I have thought of going with master/slave database configuration. The octupus gem seems to provide what I want, but since my app is huge I can't go though a millions of source code line to change the query distribution(sending read query to slave server and write query to master server). MySQL Proxy seems to be a great way to resolve this issue but since it is in alpha version I don't want to use it. So my question is what is the best way to split read/write queries across

Is this date comparison condition SARG-able in SQL?

独自空忆成欢 提交于 2019-11-28 12:13:53
Is this condition sargable? AND DATEDIFF(month,p.PlayerStatusLastTransitionDate,@now) BETWEEN 1 AND 7) My rule of thumb is that a function on the left makes condition non sargable.. but in some places I have read that BETWEEN clause is sargable. So does any one know for sure? For reference: What makes a SQL statement sargable? http://en.wikipedia.org/wiki/Sargable NOTE: If any guru ends here, please do update Sargable Wikipedia page. I updated it a little bit but I am sure it can be improved more :) Aaron Bertrand Using AdventureWorks, if we look at these two equivalent queries: SELECT

MySQL | REGEXP VS Like

本秂侑毒 提交于 2019-11-28 11:53:47
I have a table CANDIDATE in my db which is running under MySQL 5.5 and I am trying to get rows from table where RAM is contains in firstname, so I can run below two queries, but I would like to now which query we should use for long term with respect to optimization. SELECT * FROM CANDIDATE c WHERE firstname REGEXP 'ram'; SELECT * FROM CANDIDATE c WHERE firstname LIKE'%ram%'; REGEXP and LIKE are used to totally different cases. LIKE is used to add wildcards to a string whereas REGEXP is used to match an attribute with Regular Expressions. In your case a firstname is more likely to be matched

MYSQL query performs very slow

僤鯓⒐⒋嵵緔 提交于 2019-11-28 09:44:47
I have developed a user bulk upload module. There are 2 situations, when I do a bulk upload of 20 000 records when database has zero records. Its taking about 5 hours. But when the database already has about 30 000 records the upload is very very slow. It takes about 11 hours to upload 20 000 records. I am just reading a CSV file via fgetcsv method. if (($handle = fopen($filePath, "r")) !== FALSE) { while (($peopleData = fgetcsv($handle, 10240, ",")) !== FALSE) { if (count($peopleData) == $fieldsCount) { //inside i check if user already exist (firstName & lastName & DOB) //if not, i check if

How many columns is too many columns? [closed]

故事扮演 提交于 2019-11-28 07:08:36
I've noticed that a lot of folks here cite tables with 20+ (I've seen as much as 55) columns in one table. Now I don't pretend to be a database design expert, but I've always heard that this is a horrible practice. When I see this, I usually suggest splitting into two tables with a one to one relationship: one containing the most frequently used data, the other with the least often used data. Though at the same time, there's the possible issue of performance (less JOINs and such). So my question is this: When it comes to really LARGE scale databases, is there actually an advantage to having a

Mysql count performance on very big tables

自古美人都是妖i 提交于 2019-11-28 05:17:20
I have a table with more than 100 millions rows in Innodb. I have to know if there is more than 5000 rows where the foreign key = 1. I don't need the exact number. I made some testing : SELECT COUNT(*) FROM table WHERE fk = 1 => 16 seconds SELECT COUNT(*) FROM table WHERE fk = 1 LIMIT 5000 => 16 seconds SELECT primary FROM table WHERE fk = 1 => 0.6 seconds I will have a bigger network and treatment time but it can be an overload of 15.4 seconds ! Do you have a better idea ? Thanks Edit: [Added OP's relevant comments] I tried SELECT SQL_NO_CACHE COUNT(fk) FROM table WHERE fk = 1 but it took 25