database-performance

MySQL Explain rows limit

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 07:28:40
问题 Below is my query to get 20 rows with genre_id 1. EXPLAIN SELECT * FROM (`content`) WHERE `genre_id` = '1' AND `category` = 1 LIMIT 20 I have total 654 rows in content table with genre_id 1, I have index on genre_id and in above query I am limiting result to display only 20 records which is working fine but explain is showing 654 records under rows, I tried to add index on category but still same result and then also I removed AND category = 1 but same rows count: id select_type table type

MySQL: Select query execution and result fetch time increases with number of connections

戏子无情 提交于 2019-12-01 06:26:38
My server application makes multiple connections to MySQL through separate threads. Each connection fires a SELECT query and fetches result which the application then caters back to its connected users. I am using InnoDB. To my surprise I found it a very weird that if I increase number of connections to MySQL, query performance deteriorates and result fetch time also increases. Below is a table showing same. This data is produced when I had 3333 records in MySQL table and the SELECT query based on random parameters given to it fetches around 450 records out of them. Each record has around 10

T-SQL code is extremely slow when saved as an Inline Table-valued Function

馋奶兔 提交于 2019-12-01 05:22:53
I can't seem to figure out why SQL Server is taking a completely different execution plan when wrapping my code in an ITVF. When running the code inside of the ITVF on its own, the query runs in 5 seconds. If I save it as an ITVF, it will run for 20 minutes and not yield a result. I'd prefer to have this in an ITVF for code reuse. Any ideas why saving code as an ITVF would cause severe performance issues? CREATE FUNCTION myfunction ( @start_date date, @stop_date date ) RETURNS TABLE AS RETURN ( with ad as ( select [START_DATE] ,[STOP_DATE] ,ID ,NAME ,'domain1\' + lower(DOMAIN1_NAME) collate

Android SQLite alternatives [closed]

南楼画角 提交于 2019-12-01 05:18:48
I'm building a simple android RPG. Each player has access to a maximum of about 50 soldiers. Each soldier has some stats (class, hp, attack, etc), and three inventory slots. There will be only about 100 items in the game to fill these inventory slots. I was hoping to set up a relational database that would have a table for soldiers, a table for items owned, and a few other various tables. Speed is my main concern. SQLite is the obvious first choice. However, it seems to be very bulky and geared towards databases with 1000's of rows. Is there a better option for small databases? I don't need

MySQL query with JOIN not using INDEX

…衆ロ難τιáo~ 提交于 2019-12-01 05:10:57
问题 I have the following two tables in MySQL (Simplified). clicks (InnoDB) Contains around about 70,000,000 records Has an index on the date_added column Has a column link_id which refers to a record in the links table links (MyISAM) Contains far fewer records, around about 65,000 I'm trying to run some analytical queries using these tables. I need to pull out some data, about clicks that occurred inside of two specified dates while applying some other user selected filters using other tables and

Oracle 11G - Performance effect of indexing at insert

ぐ巨炮叔叔 提交于 2019-11-30 22:53:35
Objective Verify if it is true that insert records without PK/index plus create thme later is faster than insert with PK/Index. Note The point here is not about indexing takes more time (it is obvious), but the total cost (Insert without index + create index) is higher than (Insert with index). Because I was taught to insert without index and create index later as it should be faster. Environment Windows 7 64 bit on DELL Latitude core i7 2.8GHz 8G memory & SSD HDD Oracle 11G R2 64 bit Background I was taught that insert records without PK/Index and create them after insert would be faster than

Alter Non Clustered Index in SQL Server to Add more included columns

本小妞迷上赌 提交于 2019-11-30 19:33:12
Is it possible to alter an existing non clustered index to include more columns as a part of Covered columns. e.g. ALTER INDEX IX_NC_TableName_ColumnName FOR TableName(ColumnName) INCLUDE(Col1, Col2, Col3) Want to include Col4 in above index. What will be the impact of adding this column? Will there be fragmentation or anything else? The cost of an additional included column will be increased storage and potentially fragmentation. Fragmentation will increase slightly compared to the old index due to the increased leaf node size (assuming keys are not incremental) and if updates to the new

Oracle 11G - Performance effect of indexing at insert

非 Y 不嫁゛ 提交于 2019-11-30 17:53:37
问题 Objective Verify if it is true that insert records without PK/index plus create thme later is faster than insert with PK/Index. Note The point here is not about indexing takes more time (it is obvious), but the total cost (Insert without index + create index) is higher than (Insert with index). Because I was taught to insert without index and create index later as it should be faster. Environment Windows 7 64 bit on DELL Latitude core i7 2.8GHz 8G memory & SSD HDD Oracle 11G R2 64 bit

Optimal performing query for latest record for each N

此生再无相见时 提交于 2019-11-30 13:44:26
问题 Here is the scenario I find myself in. I have a reasonably big table that I need to query the latest records from. Here is the create for the essential columns for the query: CREATE TABLE [dbo].[ChannelValue]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [UpdateRecord] [bit] NOT NULL, [VehicleID] [int] NOT NULL, [UnitID] [int] NOT NULL, [RecordInsert] [datetime] NOT NULL, [TimeStamp] [datetime] NOT NULL ) ON [PRIMARY] GO The ID column is a Primary Key and there is a non-Clustered index on VehicleID

Optimal performing query for latest record for each N

依然范特西╮ 提交于 2019-11-30 08:38:06
Here is the scenario I find myself in. I have a reasonably big table that I need to query the latest records from. Here is the create for the essential columns for the query: CREATE TABLE [dbo].[ChannelValue]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [UpdateRecord] [bit] NOT NULL, [VehicleID] [int] NOT NULL, [UnitID] [int] NOT NULL, [RecordInsert] [datetime] NOT NULL, [TimeStamp] [datetime] NOT NULL ) ON [PRIMARY] GO The ID column is a Primary Key and there is a non-Clustered index on VehicleID and TimeStamp CREATE NONCLUSTERED INDEX [IX_ChannelValue_TimeStamp_VehicleID] ON [dbo].[ChannelValue] (