Questions tagged [secondary-indexes]

an index which is created other than index based on primary key, to speed up processing.

Indexing of secondary keys can only be done when the key is ordered. An index file stores the position of the record a particular category.

In this example, a secondary key is ordered alphabetically, the first record which starts with b is #14, the first record which starts with c is #26

Index file:                    Database:

Category | Start position      ID | First_name
---------|---------------      ---|-----------
a        | 1                   1  | Aaron
b        | 14                  2  | Abe
c        | 26                  ...
d        | 34                  14 | Barry

A query run on the data will be much faster, instead of looking at every record, the program can skip to start position of the category for the first letter of their name. For example, if this query was run:

SELECT First_name
FROM database
WHERE First_name = "Bryan"

The program would search for barry between records 14 - 25 rather than looking at all the records in the database.

123 questions
200
votes
7 answers

Difference between local and global indexes in DynamoDB

I'm curious about these two secondary indexes and differences between them. It is hard to imagine how this looks like. And I think, this will help more people than just me.
Michael Czolko
  • 2,698
  • 2
  • 15
  • 25
23
votes
1 answer

How to query a Dynamo DB having a GSI with only hashKeys using DynamoDBMapper

I am very new to Dynamo DB and may be this is very trivial question, but i went through the documents of Dynamo DB and stack overflow questions but i couldnt find a single link which tells how to query DDB for GSI which has only hash key and there…
Ankit Banerjee
  • 279
  • 1
  • 2
  • 6
15
votes
3 answers

how to avoid secondary indexes in cassandra?

I have heard repeatedly that secondary indexes (in cassandra) is only for convenience but not for better performance. The only case where it is recommended to use secondary indexes when you have low cardinality (such as gender column which has two…
brain storm
  • 30,124
  • 69
  • 225
  • 393
14
votes
2 answers

Optional secondary indexes in DynamoDB

I am migrating my persistence tier from Riak to DynamoDB. My data model contains an optional business identifier field, which is desired to be able to be queried as an alternative to the key. It appears that DynamoDB secondary indexes can't be null…
nullPainter
  • 2,676
  • 3
  • 22
  • 42
10
votes
1 answer

DynamoDBSaveExpression with conditional check on GSI

I want to make an update but the conditional check I want to add is not based on the Hash/Range of the primary table but of a GSI. Effectively, I want to fail the save if a given attribute (i.e. GSI's hash) already exists. As an example, in an…
instanceOfObject
  • 2,936
  • 5
  • 49
  • 85
8
votes
1 answer

Does DynamoDb allows duplicate sortKey in Index

Does DynamoDb allows duplicate sortKey in Global Secondary Index and Local Secondary Index. I have a table with partitionkey and sortKey and want to introduce GSI and LSI with different sortKey attribute, can this attribute have duplicates?
rishabhjainps
  • 410
  • 1
  • 5
  • 14
7
votes
2 answers

Clickhouse: how to use `Data Skipping Indexes` and `Manipulations With Data Skipping Indices` features in clickhouse?

I'm using the Data Skipping Indexes feature in clickhouse and i got confused about its usage. If i add a data skip index when i create the table like this: CREATE TABLE MyTable ( ... INDEX index_time TimeStamp TYPE minmax GRANULARITY…
Rujiang Ding
  • 103
  • 2
  • 6
5
votes
1 answer

Dynamodb secondary indexes latency for realtime updates

I am wondering if Amazon Dynamodb Global secondary indexes can be used for a realtime application with very heavy writes. Ex: Chat application. where global secondary indexes need to be updated in sub-millisecond latency as soon the main table…
Kans
  • 382
  • 3
  • 17
5
votes
1 answer

AWS sdk for .net queryAsync method using global secondary index fails

given below is the method I used to retrieve details from a Dynamodb table. But when I call this method it ended up throwing an exception "Unable to locate property for key attribute appointmentId". primary key of this particular table is…
Asanga Dewaguru
  • 1,058
  • 2
  • 16
  • 31
5
votes
3 answers

AWS DynamoDB v2: Do I need secondary index for alternative queries?

I need to create a table that would contain a slice of data produced by a continuously running process. This process generates messages that contain two mandatory components, among other things: a globally unique message UUID, and a message…
I Z
  • 5,719
  • 19
  • 53
  • 100
4
votes
3 answers

Creating index on existing table in Clickhouse

I am trying to add index on an existing table , with the below syntax. create table contact_in..... ( ....... domain string, topic string, category string ...... ...... ..... ..... ) ENGINE = MergeTree PARTITION BY category ORDER BY (topic, domain)…
Divyarao
  • 113
  • 2
  • 2
  • 5
4
votes
1 answer

DynamoDB scan on seconday index (GSI)

I was reading the documentation on Scan and it prefaces with: The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index.1 It made me wonder, under what circumstances would scanning a…
4
votes
2 answers

How do I create and use (or simulate) multi-column indexes in Erlang Mnesia

I have looked through the Mnesia documentation and the 3 popular Erlang books. It seems only single column primary and secondary indexes can be created and used. Or maybe it is just what the examples cover? If I create a separate index on each of…
user557513
  • 117
  • 1
  • 5
4
votes
2 answers

Symfony2/Doctrine2 get joined entities from querybuilder object

Given two doctrine entities (Person and Company), associated one-to-many, and a repository which looks something like this namespace TestBundle\Entity\Repository; use Doctrine\ORM\EntityRepository; class PersonRepository extends EntityRepository…
okdewit
  • 2,406
  • 1
  • 27
  • 32
4
votes
1 answer

Cassandra modeling with a read/unread status for a message inbox, CQL

I'm trying to find the best data model for a message box application. That messages appear in order in which first the ‘unread’ appear and then as the user scrolls the ‘read’ messages will appear. In both of the categories I want to sort the…
1
2 3
8 9