Hello,

Objects in the bucket example

{

“coordinates”: {

“latitude”: “34.006780999999997”,

“longitude”: “-118.491449”

},

type: “HotelbedsHotel”

…}

My index

CREATE INDEX

`hotelbeds_hotels_coordinates`

ON`hotelbeds_hotels`

(`coordinates`

, TO_NUMBER(`coordinates.latitude`

), TO_NUMBER(`coordinates.longitude`

))

WHERE (`type`

= “HotelbedsHotel”)

My query

select meta().id

from hotelbeds_hotels

where

TO_NUMBER(coordinates.longitude) > -118.6681759 and TO_NUMBER(coordinates.longitude) < -118.1552891

and TO_NUMBER(coordinates.latitude) > 33.7036519 and TO_NUMBER(coordinates.latitude) < 34.3373061

and type=‘HotelbedsHotel’

Query explain

## explain

{

“plan”: {

“#operator”: “Sequence”,

“~children”: [

{

“#operator”: “IndexScan3”,

“covers”: [

“cover ((`hotelbeds_hotels`

.`coordinates`

))”,

“cover (to_number((`hotelbeds_hotels`

.`coordinates.latitude`

)))”,

“cover (to_number((`hotelbeds_hotels`

.`coordinates.longitude`

)))”,

“cover ((meta(`hotelbeds_hotels`

).`id`

))”

],

“filter_covers”: {

“cover ((`hotelbeds_hotels`

.`type`

))”: “HotelbedsHotel”

},

“index”: “hotelbeds_hotels_coordinates”,

“index_id”: “578587a235e31a70”,

“index_projection”: {

“entry_keys”: [

0

],

“primary_key”: true

},

“keyspace”: “hotelbeds_hotels”,

“namespace”: “default”,

“spans”: [

{

“range”: [

{

“inclusion”: 0,

“low”: “null”

}

]

}

],

“using”: “gsi”

},

{

“#operator”: “Parallel”,

“~child”: {

“#operator”: “Sequence”,

“~children”: [

{

“#operator”: “Filter”,

“condition”: “((((((-118.6681759) < to_number((cover ((`hotelbeds_hotels`

.`coordinates`

)).`longitude`

))) and (to_number((cover ((`hotelbeds_hotels`

.`coordinates`

)).`longitude`

)) < (-118.1552891))) and (33.7036519 < to_number((cover ((`hotelbeds_hotels`

.`coordinates`

)).`latitude`

)))) and (to_number((cover ((`hotelbeds_hotels`

.`coordinates`

)).`latitude`

)) < 34.3373061)) and (cover ((`hotelbeds_hotels`

.`type`

)) = “HotelbedsHotel”))”

},

{

“#operator”: “InitialProject”,

“result_terms”: [

{

“expr”: “cover ((meta(`hotelbeds_hotels`

).`id`

))”

}

]

},

{

“#operator”: “FinalProject”

}

]

}

}

]

},

“text”: “select meta().id\nfrom hotelbeds_hotels \nwhere\nTO_NUMBER(coordinates.longitude) > -118.6681759 and TO_NUMBER(coordinates.longitude) < -118.1552891\nand TO_NUMBER(coordinates.latitude) > 33.7036519 and TO_NUMBER(coordinates.latitude) < 34.3373061\nand type=‘HotelbedsHotel’”

}

Now as you see the index works fine but I thought by creating the index with TO_NUMBER, i’ll skip the overhead needed when I do the actual query which involves TO_NUMBER… but it seems that making the index with or without TO_NUMBER yields the same performance.

I tried the same scenario on a data where the numbers are stored numbers (not literals) and the performance was much quicker, we’re talking ~ 8ms to 1.5secs

Any tips how can I enhance my query performance in my scenario?

Thanks a lot