Questions tagged [compound-index]

Indexes with multiple columns in the same one index.

For questions about indexing a database by multiple columns at once.

116 questions
0
votes
0 answers

Calculating growth index of stock performance which is reseted every four years

I am analysing a stock-index in 4-year cycles and would like to start with a base of 1 at the beginning of the first year and the calculate the returns on top, so that I get a column in the dataframe that goes 1, 1.02, 1.03, 1.025... The return…
Markus W
  • 1,451
  • 5
  • 19
  • 32
0
votes
0 answers

Parse DB/Mongo compound index with an OR and an Object

I am working on a project where the data is stored in a very weird shape that's causing the query for finding an user on first login attempt to TAKE A LONG TIME. I'm having a hard time wrapping my mind around how I can create an index for this. I…
0
votes
3 answers

R function - Index

since there is no R package, I have a question concerning the creation of an own function to calculate the SAPEI index - standardized antecedent precipitation evapotranspiration index ("A standardized index for assessing sub-monthly compound dry and…
Fabián
  • 21
  • 2
0
votes
1 answer

MongoDB: ensure uniqueness across multiple documents and fields

I have a collection of documents storing user information as: { "username": "alex", "username_1": "mark", "username_2": "james" } } I would like to ensure uniqueness both at global (throughout the whole collection) and document…
Alessandro Ceccarelli
  • 1,775
  • 5
  • 21
  • 41
0
votes
1 answer

How to create a compound index for speicifc documents in mongodb

I'm running MongoDB 4.2, see below how my documents look like: { "_id" : ObjectId("61e8e5b72e74b7fc3e16b632"), "1" : 2, "age_upon_outcome" : "1 year", "animal_id" : "A725717", "animal_type" : "Cat", "breed" : "Domestic…
Pedro
  • 3
  • 1
0
votes
0 answers

How to optimise the FETCH stage of a Mongo query?

I have the following query db.getCollection("order_error").find({ "$and":[ { "type":"orderResult" }, { "Origin.SN":{ "$in":[ "5701097", "5701099" ] …
0
votes
3 answers

Which indexes are necessary?

If I have a table TABLE_1 with, lets say 5 columns: COL1 | COL2 | COL3 | COL4 | COL5 [line] [line] [...] And there are two main queries I want to do: SELECT * FROM table_a WHERE COL1 = 'X' and COL2 = 'Y' And the other…
filippo
  • 5,583
  • 13
  • 50
  • 72
0
votes
0 answers

MongoDB - Index usage for different queries with the same results

I have 2 queries with the same result as below: Query 1: { $or: [ { field_1: "A", }, { field_2: "B", }, ], field_3: "C", }, Query 2: { $or: [ { field_1:…
Tri Nguyen
  • 93
  • 2
  • 7
0
votes
1 answer

mongoDB: does sorting by an inverted non-prefix index subset match the entire index when querying with index prefix?

MongoDB documentation https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/#sort-on-multiple-fields: For a query to use a compound index for a sort, the specified sort direction for all keys in the cursor.sort() document must match…
crunk1
  • 2,560
  • 1
  • 26
  • 32
0
votes
0 answers

MongoDb Indexes - Equal vs In filter and index usage

I've the follolowing model of a user { "TenantId":"abc", "ContainerId": "xyz", "Name": "yyy", "Tags": [ { "Key":"key1", "Value":"val1". } ..... ] } TenantId and containerId are in relation 1:n,…
macpak
  • 1,190
  • 1
  • 14
  • 28
0
votes
1 answer

MongoDB Compound Index Prefix with Sort

I have trouble deciding where to best put sorting field in a mongodb compound index. My understanding is that we need to choose the highest cardinality & selectivity as the preceeding fields in a compound index db.person.createIndex({ rating: 1,…
user1955934
  • 3,185
  • 5
  • 42
  • 68
0
votes
1 answer

T-SQL compound index sufficient for query on subset of columns?

Is a compound index sufficient for queries against a subset of columns ? CREATE TABLE [FILE_STATUS_HISTORY] ( [FILE_ID] [INT] NOT NULL, [STATUS_ID] [INT] NOT NULL, [TIMESTAMP_UTC] [DATETIME] NOT NULL, CONSTRAINT…
BaltoStar
  • 8,165
  • 17
  • 59
  • 91
0
votes
2 answers

Update unique compound indexes on an existing data set

Problem: I'm trying to update a unique compound index on an existing data set and Mongo isn't updating the index. Background: In the database for our web app we have a unique compound index using a user's clubID and email. This means emails must be…
Sam Gruse
  • 488
  • 1
  • 5
  • 11
0
votes
1 answer

Mongodb compound index is not in use with query

Hi can somebody explain me please how to make compound index for this simple query? find({ "userId":{"$in":["5c778c4f52732c06d3384269","5b274b672a35d168960b1bd5","5bc43d6552732c527345c35d","58ec836e899753a22b95fb19"]}, "end":{"$gte":…
Čamo
  • 3,863
  • 13
  • 62
  • 114
0
votes
1 answer

Mongodb compound indexes for filtering and sorting on BIG collection

Can somebody tell me please if is possible to make indexes in Mongodb more efficient in this case: I have database with 50 millions items. There are two indexes on fields "ico" and "publishDate". Ico is used for filtering and publishDate for…
Čamo
  • 3,863
  • 13
  • 62
  • 114