query-optimization

JOIN queries vs multiple queries

可紊 提交于 2019-11-26 02:51:15
问题 Are JOIN queries faster than several queries? (You run your main query, and then you run many other SELECTs based on the results from your main query) I\'m asking because JOINing them would complicate A LOT the design of my application If they are faster, can anyone approximate very roughly by how much? If it\'s 1.5x I don\'t care, but if it\'s 10x I guess I do. 回答1: This is way too vague to give you an answer relevant to your specific case. It depends on a lot of things. Jeff Atwood (founder

How to do the Recursive SELECT query in MySQL?

萝らか妹 提交于 2019-11-25 22:06:06
问题 I got a following table: col1 | col2 | col3 -----+------+------- 1 | a | 5 5 | d | 3 3 | k | 7 6 | o | 2 2 | 0 | 8 If a user searches for \"1\", the program will look at the col1 that has \"1\" then it will get a value in col3 \"5\", then the program will continue to search for \"5\" in col1 and it will get \"3\" in col3 , and so on. So it will print out: 1 | a | 5 5 | d | 3 3 | k | 7 If a user search for \"6\", it will print out: 6 | o | 2 2 | 0 | 8 How to build a SELECT query to do that?

How to describe performance issue in relational database?

点点圈 提交于 2019-11-25 21:59:20
问题 I have a query running in a relational database that doesn\'t fulfill the expectation of the users. What information should I provide and what should I avoid, so that I can receive an effective help on this site? 回答1: For Oracle Database provide this information: Describe the symptoms of the problem Describe the behavior that cause the problem. Is the behavior of the query stable or does the problem occurs only sometimes, with specific parameters or simple random. Can you reproduce this

PostgreSQL LIKE query performance variations

好久不见. 提交于 2019-11-25 21:59:09
问题 I have been seeing quite a large variation in response times regarding LIKE queries to a particular table in my database. Sometimes I will get results within 200-400 ms (very acceptable) but other times it might take as much as 30 seconds to return results. I understand that LIKE queries are very resource intensive but I just don\'t understand why there would be such a large difference in response times. I have built a btree index on the owner1 field but I don\'t think it helps with LIKE