Questions tagged [composite-index]

Composite index: An index that contains more than one column.

A composite index is useful when there are multiple fields in the WHERE clause of an SQL statement and all fields combined will give significantly less rows than the first WHERE clause field.

81 questions
0
votes
1 answer

firestore REST order by 2 fields ( composite query )

the firestore REST documentation doesn't mention info about compound queries https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases.documents/list How can I order by 2 fields when querying a list of documents ? ( for…
Ninja Dev
  • 816
  • 8
  • 10
0
votes
1 answer

Why is MySQL preferring a single index over a composite index?

I currently have this query: SELECT * FROM (`session`) WHERE (`session`.`isSale` = 0) AND (`session`.`createDatetime` >= (NOW() - INTERVAL 3 WEEK)) AND (`session`.`sellerName` IS NOT NULL) GROUP BY `session`.`id` ORDER…
Patrick Younes
  • 139
  • 1
  • 15
0
votes
2 answers

How to create Composite index in Hazelcast

I am trying to improve performance of Hazelcast lookup by using composite key. I have a class entity Class Entity { private Long id; private String field1; private String field2; private String field3; // getter and setters } I…
0
votes
2 answers

Can I have multi-order index for composite/multi-column index in MySQL?

I have an invoices table like this: | id | client_id | is_recurring | |----- |-----------| -------------| | 1 | 2121 | 0 | | 2 | 7434 | 1 | Now throughout my application, I might have following…
Jaber Al Nahian
  • 903
  • 10
  • 15
0
votes
1 answer

Optimize my query (indexes, EXPLAIN) Mysql

With the help of developers here on stackoverflow, I have been able to optimize my query to perform better than it was initially doing. Execution time dropped to: 1.2s However, after doing EXPLAIN on the query, it seemed like the…
0
votes
1 answer

What is the size of a composite index in MySQL/MariaDB

Suppose I have three columns, A, B, C. They each have a range of x, y and z possible values respectively. Does an index on all three columns have a size proportional to x * y * z?
lbj99
  • 3
  • 1
  • 2
0
votes
1 answer

Does a MySQL database use a composite index when one of the fields in the WHERE clause is null?

Say I have a composite index consisting of the fields (commentId, journalEntryId, owning_comment_id ). Now let's say that I have the following query: UPDATE comments c SET c.acceptedAsAnswer = isAnswer WHERE c.id = commentId AND…
Maurice
  • 6,698
  • 9
  • 47
  • 104
0
votes
1 answer

Query on Indexing when Firestore collection has Timestamp field

I have a Firestore project where my collection feed has a timestamp field createdDate. As I am querying the feeds based on the created time with other fields, I have created a Composite Index including the timestamp field. In the Indexing best…
0
votes
1 answer

Composite Index in Google Cloud Datastore

I have a kind name 'Wdr'. My index.yaml file looks like this . indexes: -kind: Wdr ancestor: yes properties: -name : wdr_id -name : wdr_sub_id direction: desc I am not able to run this gql query below. SELECT * FROM Wdr where wdr_id = '1098'…
0
votes
0 answers

index on composite primary key columns

I have table called CREATE TABLE process ( batch_id Integer ,product_id Integer ,machine_id Integer ,created_date DATE ,updated_date DATE ,primary key(batch_id,product_id,machine_id) ) But I generally use SQL…
Ganesh Jadhav
  • 616
  • 2
  • 7
  • 21
0
votes
1 answer

"Using index" with composite index: A=, B=, C<=

The execution plans below seem disappointing and suboptimal, even though the queries are straightforward. I'm using MySQL 5.7. Here is the fiddle (although it only offers 5.6). CREATE TABLE `event` ( `id` BIGINT(20) UNSIGNED NOT NULL…
Timo
  • 7,992
  • 4
  • 49
  • 67
0
votes
0 answers

Flutter cloud firestore range base query

What I'm trying to do: I have a collection called "Users" where each user(document) has its own latitude and longitude saved inside of that file. With that, I'm trying to do a query which will look something like this. _firestore …
Mircea
  • 1,671
  • 7
  • 25
  • 41
0
votes
0 answers

Adding index for date field rails

We are using soft delete in our project. So by default, each query will produce with where condition as "deleted_at is NULL" and when using some other scopes(only_deleted) query may be "deleted_at is NOT NULL". In this case, is it necessary to add…
Aarthi
  • 1,451
  • 15
  • 39
0
votes
1 answer

PostgreSQL index on multiple columns, when is it too much?

Using PostgreSQL 9.6 I have a table with some values I want to filter on and order by time: a timestamp (may be range selected in the UI) status string (only a few known values for now, also selectable in the UI) context (scope of the data in the…
Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
0
votes
1 answer

gae datastore composite index rebuild / update for new entities

I'm using GAE Datastore composite index and successfully created composite index 2 days ago. The index is in "serving" state. However the index is not automatically updated for new entries. Do I have to wait for it to be updated automatically, or I…