database-indexes

Why MongoDB doesn't use Index Intersection?

牧云@^-^@ 提交于 2020-01-03 07:29:18
问题 I am trying to reproduce the first example of index intersection instruction (http://docs.mongodb.org/manual/core/index-intersection/) but facing a problem: mongo doesn't uses both indexes My steps: Download mongo (3.0.3) and install it Run mongod: mongod.exe --dbpath d:\data (folder is empty) Run mongo: mongo.exe Add indexes: db.orders.ensureIndex({ qty: 1 }) db.orders.ensureIndex({ item: 1 }) db.orders.getIndexes() [{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "test.orders" },

primary indexes Vs secondary indexes: performance differences

半世苍凉 提交于 2019-12-30 07:32:51
问题 I've got a little question: what is the difference in performance between the primary and secondary indexes? what causes this difference? I'm googling around, and I've seen that secondary indexes are stored in another table, so this slows down all operations.. but there are some other reasons that justify this decrease in performance? Thanks a lot 回答1: A clustered table is a B-Tree without "heap" portion - rows are stored directly in the B-Tree structure of the clustering index (primary key).

Indexing a column having duplicate values

和自甴很熟 提交于 2019-12-24 19:30:50
问题 Consider these tables: seed (seedid, seedname) # PK-(seedid) stock (seedid, stk, storeid) # PK-(seedid,storeid), FK-(storeid) #InnoDB stock: seedid, stk, storeid 1 12 81 2 13 81 3 14 81 1 12 82 2 11 82 3 13 82 4 12 82 Query -> select stk from stock where seedid = 'aaa' and storeid = 'yyy'. Table stock represent stocks of several stores, hence storeid will be repeated over. How do I index, table stock , given that it will be queried frequently using storeid ? Primary keys as automatically

MySQL not picking correct row count from index

寵の児 提交于 2019-12-24 07:09:07
问题 I have a following table CREATE TABLE `test_series_analysis_data` ( `email` varchar(255) NOT NULL, `mappingId` int(11) NOT NULL, `packageId` varchar(255) NOT NULL, `sectionName` varchar(255) NOT NULL, `createdAt` datetime(3) DEFAULT NULL, `marksObtained` float NOT NULL, `updatedAt` datetime DEFAULT NULL, `testMetaData` longtext, PRIMARY KEY (`email`,`mappingId`,`packageId`,`sectionName`), KEY `rank_index` (`mappingId`,`packageId`,`sectionName`,`marksObtained`), KEY `mapping_package` (

mysql and indexes with more than one column

大憨熊 提交于 2019-12-24 00:59:13
问题 How to use indexes with more than one column The original index has an index on block_id , but is it necesarry when it's already in the unique index with two column? Indexes with more than one column (a,b,c) you can search for a, b and c you can search for a and b you can search for a you can not search for a and c Does this apply to unique indexes too? table id block_id account_id name indexes origin PRIMARY KEY (`id`) UNIQUE KEY `block_id` (`block_id`,`account_id`) KEY `block_id` (`block_id

Why are these SQL Server statistics outdated, when it's set to auto-update?

倖福魔咒の 提交于 2019-12-23 19:24:00
问题 We have a SQL Server 2012 instance, with auto-statitics set to ON for the DB: But then i ran a query to check some statistics, and some haven't been updated in a while: Why is this the case? Is there a rule to whether SQL Server updates statistics that haven't been triggered by these indexes? Do i need to care? How do i know if i need to update them, or if they are causing performance issues for me? Thanks! 回答1: Even though you set Auto update statistics to true, they will update only when a

Why does the presence of primary key on the table significantly enhance the performance of column-store indexes?

匆匆过客 提交于 2019-12-21 19:58:27
问题 I was trying to see the kind of performance gains column-store indexes can provide on a table. The table has about a 3.7 million rows, 11 columns and is stored as a heap (i.e without a primary key). I create a column-store index on the table and run the following query: SELECT [Area], [Family], AVG([Global Sales Value]) AS [Average GlobalSalesValue], COUNT([Projected Sales]) FROM dbo.copy_Global_Previous5FullYearSales WHERE [Year] > 2012 GROUP BY [Area], [Family] The create table statement is

Creating case-insensitive indexes on Postgres string array

为君一笑 提交于 2019-12-20 02:38:28
问题 I'm using a varchar[] column (varchar array) in Postgres 9.2 to store some tags. While retrieving rows by tags, I want the query to be case insensitive. However, I want to preserve the case to display in the UI (therefore I can't just store everything as lower case). So, my question is how do I create a case-insensitive index in Postgres over a varchar array? One possible approach would be to create a functional GIN index on the column. How does one do that? Any other approaches? 回答1:

Are POSIX' read() and write() system calls atomic?

这一生的挚爱 提交于 2019-12-17 20:15:40
问题 I am trying to implement a database index based on the data structure (B link tree) and algorithms suggested by Lehman and Yao in this paper. In page 2, the authors state that: The disk is partitioned in sections of fixed size (physical pages; in this paper, these correspond to the nodes of the tree). These are the only units that can be read or written by a process. [emphasis mine] (...) (...) a process is allowed to lock and unlock a disk page. This lock gives that process exclusive

A list of indices in MongoDB?

廉价感情. 提交于 2019-12-17 17:41:32
问题 Is there a way to see a list of indices on a collection in mongodb in shell? i read through http://www.mongodb.org/display/DOCS/Indexes but i dont see anything 回答1: From the shell: db.test.getIndexes() For shell help you should try: help; db.help(); db.test.help(); 回答2: And if you want to get list of all indexes in your database: use "yourdbname" db.system.indexes.find() 回答3: If you want to list all indexes: db.getCollectionNames().forEach(function(collection) { indexes = db[collection]