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
0
votes
1 answer

How are secondary indexes used in search engines like elasticsearch?

I have been reading Designing Data-Intensive Applications lately. In Chapter 6 on partitioning (sharding), the author talks about the need for secondary indexes in storage systems. In particular, the author says: And finally, secondary indexes are…
wlnirvana
  • 1,811
  • 20
  • 36
0
votes
1 answer

Conditionally adding/removing records to DynamoDb global secondary index

I have a base DDB table Attachment and it has 2 fields called customerState and isIntermediateState. customerState can be Attaching, Detaching, Attached and Detached. isIntermediateState can be 1 (if customerState == Attaching || Detaching) or 0 (if…
0
votes
0 answers

Update dynamoDB gsi composite sort key

My dynamoDB table has a GSI which its sort key is composite key. This composite key looks like this: #STATUS#CREATED_AT. The status field can be changed during update action on item, but I noticed even if I change the GSI_sk in primary table, this…
0
votes
1 answer

MySQL query performance on secondary index

I have a issue about select query performance . My table DDL(gen from show create table test) as below: CREATE TABLE `test` ( `id` bigint NOT NULL, `issue_code` varchar(10) DEFAULT NULL, `issue` char(12) DEFAULT NULL, PRIMARY KEY (`id`), …
linlowa
  • 13
  • 1
  • 5
0
votes
1 answer

Why does MySQL ignore index in this query?

I have the following tables: CREATE TABLE `sms` ( `sms_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `sms_datetime` datetime DEFAULT NULL, `sms_number` varchar(40) NOT NULL, `sms_text` text, `sms_status` int(3) DEFAULT '0', `sms_last_tm`…
tonix
  • 6,671
  • 13
  • 75
  • 136
0
votes
0 answers

what is the difference between secondary index and non-clustered index

I'm studying about indexes in a database and I'm having some ambiguity. In a non-clustered index, we learned that the datafiles are not sorted and that each index entry points to a record in the datafile. However, the secondary index doesn't seem to…
user13242010
0
votes
2 answers

In DynamoDb, is there a way to atomically check a secondary index for an item before writing it?

I've got an object like this: { "id": (UUID generated at call time) "referenceId": (Foreign key for another system) "referenceType": (enum) } The primary index is just Primary key: id And I've got a secondary index like Primary…
StolenKitten
  • 337
  • 1
  • 10
0
votes
1 answer

How can i use Parallel Scan of AWS DynamoDB to run scan on a specific GSI?

I have a DynamoDB table where each Item has a key of the name 'DataType'. Also there is a GSI on this table with this 'DataType' as the HashKey and 'timestamp' as rangeKey. Around 10 per cent of the table items have the 'DataType' value as 'A'. I…
0
votes
1 answer

Dynamo db sorting

I have a scenario in which I will have to list the incoming requests of a user sorted based on creation time and priority(High, Medium, Low) along with pagination. Is there a way to achieve this in dynamoDb ? Right now I'm using a secondary Index…
0
votes
2 answers

Redis Secondary Indexes and Performance Question

I know that Redis doesn't really have the concept of secondary indexes, but that you can use the Z* commands to simulate one. I have a question about the best way to handle the following scenario. We are using Redis to keep track of orders. But we…
Westy
  • 169
  • 2
  • 15
0
votes
2 answers

MySQL - Order of results guarantee when fetching data using a secondary index column

If I have a table with an index on a secondary column, does fetching data using the secondary column guarantee that the results are always in a consistent order? For example, say I have a table T, with columns PKColumn, ColumnA, ColumnB,…
java_geek
  • 17,585
  • 30
  • 91
  • 113
0
votes
0 answers

Fetch data based on secondary index in EF Core

I want to understand how can data be retrieved efficiently in EF Core if I have defined a secondary index (non-clustered) for my table. I want to be able to do efficient lookups of single elements based on the secondary index: public class Entity { …
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
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
1 answer

Create secondary global index for existing dynamoDB table using CloudFormation

The DynamoDB table is already created and running in production. As per current use-case, planning to add new secondary global index. This can be achieved via AWS SDK, is it possible to update DynamoDB table with CloudFormation script. Any helps…
Ravikumar
  • 1,121
  • 1
  • 12
  • 23
0
votes
1 answer

Pagination with secondary index with DynamoDB/Node.js

I have a problem with the pagination of a global secondary index in Dynamodb :/ My DynamoDB schema is: Resources: ImportsTable: Type: AWS::DynamoDB::Table Properties: # Generate a name based on the stage TableName:…
1 2 3
8 9