2

It's just a doubt that i cant find on the internet.
I have a table like this:

|  id | infos | ignored |
|  1  | abc  | true       |
|  2  | def   | false      |
|  3  | ghi   | false      |

I see i cant create a DynamoDB GSI on booleans columns. It's right?
I want to create a GSI on this ignored column.

Rafael de Carvalho
  • 501
  • 1
  • 5
  • 10

1 Answers1

3

The DynamoDB console only allows GSIs using types of string, binary, or number.

enter image description here

So you could use strings ("t" or "f"), numbers (1 or 0) or binary (also 1 or 0) to represent a boolean value if you'd like.

It sounds like you're trying to build a sparse index (e.g. only certain items are in the index). Keep in mind that you can do this by the mere existence of the attribute that makes up the GSI.

For example, you could include the ignored attribute on items you want to project into the index and remove the ignored attribute from items you do not want in the index.

Seth Geoghegan
  • 5,372
  • 2
  • 8
  • 23
  • 1
    Yes — and important to stress that a sparse index will perform a lot better when it is truly sparse (i.e in general it is a bad idea to partition on a boolean value, but indexing on a low cardinality sparse boolean will actually work very well) – Mike Dinescu Nov 29 '20 at 18:30