sqlperformance

SQL Server SELECT INTO and Blocking With Temp Tables

﹥>﹥吖頭↗ 提交于 2019-11-27 11:37:35
问题 So, recently a DBA is trying to tell us that we cannot use the syntax of SELECT X, Y, Z INTO #MyTable FROM YourTable To create temporary tables in our environment, because that syntax causes a lock on TempDB for the duration of the stored procedure executing. Now, I've found a number of things that detail how temporary tables work, scope of execution, cleanup and the like. But for the life of me, I don't see anything about blocking because of their use. We are trying to find proof that we

Should every User Table have a Clustered Index?

无人久伴 提交于 2019-11-27 01:02:49
Recently I found a couple of tables in a Database with no Clustered Indexes defined. But there are non-clustered indexes defined, so they are on HEAP. On analysis I found that select statements were using filter on the columns defined in non-clustered indexes. Not having a clustered index on these tables affect performance? It's hard to state this more succinctly than SQL Server MVP Brad McGehee : As a rule of thumb, every table should have a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases–such as an identity column, or some

Database/SQL: How to store longitude/latitude data?

心已入冬 提交于 2019-11-26 23:54:18
问题 Performance question ... I have a database of houses that have geolocation data (longitude & latitude). What I want to do is find the best way to store the locational data in my MySQL (v5.0.24a) using InnoDB database-engine so that I can perform a lot of queries where I'm returning all the home records that are between x1 and x2 latitude and y1 and y2 longitude . Right now, my database schema is --------------------- Homes --------------------- geolat - Float (10,6) geolng - Float (10,6) ----

Difference between Key, Primary Key, Unique Key and Index in MySQL

烂漫一生 提交于 2019-11-26 13:53:37
When should I use KEY , PRIMARY KEY , UNIQUE KEY and INDEX ? KEY and INDEX are synonyms in MySQL. They mean the same thing. In databases you would use indexes to improve the speed of data retrieval. An index is typically created on columns used in JOIN , WHERE , and ORDER BY clauses. Imagine you have a table called users and you want to search for all the users which have the last name 'Smith'. Without an index, the database would have to go through all the records of the table: this is slow, because the more records you have in your database, the more work it has to do to find the result. On

Difference between Key, Primary Key, Unique Key and Index in MySQL

╄→гoц情女王★ 提交于 2019-11-26 05:54:48
问题 When should I use KEY , PRIMARY KEY , UNIQUE KEY and INDEX ? 回答1: KEY and INDEX are synonyms in MySQL. They mean the same thing. In databases you would use indexes to improve the speed of data retrieval. An index is typically created on columns used in JOIN , WHERE , and ORDER BY clauses. Imagine you have a table called users and you want to search for all the users which have the last name 'Smith'. Without an index, the database would have to go through all the records of the table: this is