Commit Graph
93 Commits
Author SHA1 Message Date
Murat Tuncer fa1cf1d0d1 Merged PR 1300043: Fix git index file path
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
check for the git index file assumed specific placement of the root dir and failed
when used as submodule

This fix make sure git can find the index file
2024-03-22 11:28:50 +03:00
Vinod Sridharan 53bf641ad3 Merged PR 1300971: [Hash] Improve Group/Distinct/Lookup Performance
### Does this PR have any customer impact?
Yes - in 1.16
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description

In Postgres default behavior for Group by/Distinct is to ORDER BY the Grouping term/Distinct which means building a tuple sort + Ordering it before doing the group.

However, if the type defines a hash operator class then the GROUP will use a HashAgg instead of OrderedAgg which is better since it only needs to handle equality (and not Sorted).

Implement a bson hash operator class and add it to 1.15. When the schema deploys it will automatically pick this in the planner.
2024-03-22 11:28:50 +03:00
Vinod Sridharan 7c778c19f8 Merged PR 1296261: Graphlookup part2 - Enable Tests and fix up issues
### Does this PR have any customer impact?

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

From the remaining TODOs handles the following:

- [Done] To handle arrays we do a `$unwind` - move that to doing an eq/in based on the input: This is done by adding a makeArray aggregation operator and using that with `$in` expression
- [Done] Think about cycles: Add a visited check and ignore nodes that are visited before.
- [Done] Need to handle maxDepth infinite recursion more gracefully with $graphLookup.
- [Done] Need to validate against jstests

Still TODO:
- More testing on dotted paths and arrays & reducing traversals
- Implement a hash aggregate operator class for BSON
2024-03-22 11:28:50 +03:00
Vinod Sridharan 6e23d4ff85 Merged PR 1300893: [Misc] Index changes and bugfixes
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix/Features

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
1) Enable fast scan by default
2) Fix memory leaks in unique index creations
3) Add option to enable large index keys on an account basis by default
4) Introduce Index term version v1 as a valid version for single path indexes
5) Use index version v1 to ensure metadata terms are marked metadata
6) Enable index term truncation by default on V1 index version
2024-03-22 11:28:50 +03:00
Ujjwal Agrawal ee172ea8d1 Merged PR 1279069: $centerSphere geo operator part 2: add support for all GeoJson types
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
pgmongo_1.14.md

### Description
Add support for all GeoJson types with $centerSphere.
Postgis returns true if 1 out of n points in the doc's GeoJson lies inside the query, but mongodb returns true only if all points are inside. So I added runtime check for all points.
Also added a better way to iterate through WKB buffer without having to worry about segfault if traversal overflows (See IncrementBufferDataBySize in geospatial_query_operator)

Related work items: #2928131
2024-03-22 11:28:50 +03:00
Santiago Fernandez Madero 400da6cd09 Merged PR 1274835: Introduce non exists index term for exists and null equality scenarios
With 100K documents optimizes $exists:true/false in the index from 5x -> 10x depending on the query and scenario now that $exists is not a partial match for non-wildcard indexes.

The optimization uses a new term, the non-exists term, which is a term with no path `""` and of bson type `undefined`, which is generated when the document doesn't contain a field for the indexed path.

This gives us more information when doing index evaluations and we can compare against the non-exist term when doing null equality comparisons or exists checks.
2024-03-15 13:58:37 +03:00
Deepak Bisht 9d49cabefa Merged PR 1295076: [Geospatial] - Fix results not returned when the query WKB is big
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Bug fix while creating the WKB for geometries/geographies where we fill the number of components later (num of points, num of linestring, num of polygons, num of geometries etc) after doing the traversal.
Earlier we used to store the memory address of the place where the `number` is needed to be updated but thats bad because with larger geometries, reallocation of buffer happens and we were losing the place to update the `number`; now instead of storing the memory address, we store the the position relative to the start of buffer so even if the memory is reallocated we know where to add the `number`.

Related work items: #3012835
2024-03-15 13:58:37 +03:00
Murat Tuncer 8d9bef2a79 Create codeql.yml 2024-03-14 13:51:15 +03:00
Vinod Sridharan 6a699bcd46 Merged PR 1289862: Part 1: Skeleton for the GraphLookup aggregation Stage
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Implement the basic skeleton for $graphLookup under a feature flag.

Remaining TODOs:
1) To handle arrays we do a $unwind - move that to doing an $eq/$in based on the input
2) Implement a hash aggregate operator class for BSON so we can use a UNION query instead of UNION ALL
3) Need to validate against jstests
4) Need to handle maxDepth infinite recursion more gracefully with $graphLookup.
5) More testing on dotted paths and arrays
6) Think about cycles

Related work items: #1798581
2024-03-08 14:01:20 +03:00
Abhishek Johri 965f1b05f7 Merged PR 1291617: Flaky test fix for $currentDate tests
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Flakyness fix in $currentDate tests.
It appears to be rounding error and failure log didnt give much info.
Took these steps to eleminate (or atleast reduce flakyness)
- Used FLOOR/CEIL instead of ROUND to be in control of what we want.
- Used correct datatype (reduced unnecessary typecasting, and usage of numeric datatypes).
- Added better error log, so that if a test fails, we will know, if it's a real issue of big time difference and not just rounding error.

Related work items: #2999363
2024-03-08 14:01:20 +03:00
Santiago Fernandez Madero a770e351e6 Merged PR 1289897: Add inverse match UDF to 1.14 schema to be able to use it sooner in prod
Add inverse match UDF to 1.14 schema to be able to use it sooner in prod

This UDF will be used for the new $inverseMatch aggregation stage which will take the document to apply the match on, the path where the document defines the query and the input value to evaluate the query against.

Since we need a UDF to do this against every document in a query like so:

```
SELECT document FROM mongo_data.documents_1_102045 collection WHERE helio_api.bson_dollar_inverse_match(document,{ "path": "a", "input" : [ { "foo" : { "$numberInt" : "3" } } ] }'::mongo_catalog.bson)
```

This is schema dependent, let's add a no-op UDF so that we can use the 1.14 train and that way in the 1.15 branch it will be already available to be used by the binary since we ship schema n-1 always.
2024-03-08 14:01:20 +03:00
Deepak Bisht a5b6ae4c51 Merged PR 1288929: decreased log level to DEBUG1
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Logging

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
decreased log level to DEBUG1 for decimal 128 operations
2024-03-08 14:01:20 +03:00
Ayush Saluja affba201b1 Merged PR 1276508: $DateFromParts aggregation operator
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Adds support for $dateFromParts aggregation operator

Related work items: #2019203
2024-03-08 14:01:20 +03:00
Deepak Bisht 68db65384e Merged PR 1289024: fix seg fault in currentOp
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
fix seg fault in currentOp while reading blocking PIDs for an acitivity. Currently it was read as a varlen data but it is INT8 and should be read as by value.
2024-03-08 14:01:20 +03:00
Santiago Fernandez Madero dba20f6b85 Merged PR 1288356: Move main to 1.15 binary and 1.14 schema and fix rename collection version
### Description

Move main to 1.15 binary and 1.14 schema and fix rename collection version

Rename collection PR went in after we forked the 1.14 release branch but before main was bumped to the new schema and binary version, so fix that in this PR as well.
2024-03-04 09:53:14 +03:00
Vinod Sridharan 6e12b04f2d Merged PR 1288570: Improve stability of backend tests
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
- Remove Buffers from explain - it's not stable across runs and PG versions
- in the scenario where you had an intersection filter, when we set the cost to 0, a bitmapAnd path could be picked. Ensure for PK lookups we always prefer the PK index.
2024-03-04 09:53:14 +03:00
Vinod Sridharan c00dcf25a4 Merged PR 1288370: [Tests] Make more tests pass
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Make more JSTests pass by implementing or fixing bugs
2024-03-04 09:53:14 +03:00
Lucas Borges Fernandes b635c244d8 Merged PR 1249041: [OSS] Adding C impl for rename_collection UDF 2024-03-04 09:53:14 +03:00
Vinod Sridharan 38ae02ad41 Merged PR 1286968: [JSTests] Make exclusion test pass
### Does this PR have any customer impact?

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

More

Related work items: #2453917
2024-03-01 17:24:28 +03:00
Zinan Ren 🐾 29b57abc36 Merged PR 1287426: [Vector Search] Enable HNSW index by default
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
We will enable the HNSW index on SKU m40 and above.
The GUC pgmongo.enableVectorPreFilter is "on" by default, on the lower SKUs it will be set to be "off" by control plane

Related work items: #2600904
2024-03-01 17:24:28 +03:00
Tanvi Bhandari 8d461c2b27 Merged PR 1271218: CurrentOp showing the progress for Index Build in background
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Issue:
Since the owner of scheduled cron job for index build background is admin user i.e. 'postgres' in prod, the CREATE INDEX CONCURRETLY queries are owned by 'postgres' user in pg_stat_activity.
And non-admin user who requests for currentOp to get progress of running indexes, does not have enough privilege to read queries owned by admin user in pg_stat_activity.

Solutions:
From inside running cron-job, create LibPQ connection as the non-admin user for CREATE INDEX CONCURRENTLY. The pre-requisite for this approach is that we have the information of user-oid who has submitted the request in queue. I.e. This needs user_name column in index_queue table.

Related work items: #2961369
2024-03-01 17:24:28 +03:00
Vinod Sridharan 186cf63fcd Merged PR 1285018: [Range] Improve Range Filter Performance
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
N/A
### Description
Improve performance of $range opertor.

Two points:
1) Generalize support so queries like a = 1 AND b > 5 AND b < 6 can now use $range
2) We were sitll evaluating a runtime filter when we used $range. Remove the excess filter.
2024-03-01 17:24:28 +03:00
Vinod Sridharan a69e998708 Merged PR 1283564: [PG16] Move Mariner tests to PG16
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
DevOps

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Moves the Mariner tests to PG16 instead of PG15.
2024-03-01 17:24:28 +03:00
Vinod Sridharan d4018f7a46 Merged PR 1283033: [PG16] Part2: Enable backend tests for PG16
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Changes:
- Unify rum_tuplesort_get_estimated_itemcount between PG16/PG15
- Remove set local force_parallel_mode TO ON; - This flag is removed in PG16
- Remove legacy query generation for lookup tests
- Citus 12.1 made the default behavior not to push down filters - set htat GUC to true for the extension
2024-03-01 17:24:28 +03:00
Tim Conley 04450d193d Merged PR 1280286: Add single batch for DataApi aggregates
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
2024-03-01 17:24:28 +03:00
Vinod Sridharan 0e156314f6 Merged PR 1282170: [PG16] Enable building the extension with PG16
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Infra

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Part 1: Enable building the extension and fix up pieces for building with PG16.

With this the core extension builds with PG16 and *most* of the backend tests pass. At this point, checking this in as a checkpoint (to ensure compat is retained) as more features are lit up with PG16

One thing to note is PG16 builds changes the default visibility of exports to 'private' that means that to make the current build work, we need to override that to 'default/public'. This needs to be fixed but is left as-is currently to make incremental progress.

There were some attempts to create exports in the code that are left as-is
2024-03-01 17:24:28 +03:00
Jayanta Mondal e916817aa6 Merged PR 1276499: [backend] Skipping optimizing with only $in
### Does this PR have any customer impact?

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

single  fix
2024-03-01 17:24:28 +03:00
Vinod Sridharan 3b6e07f30f Merged PR 1281490: Query operator native support part 1: Enable expansion of the query operator
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes (OSS)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Today in OSS the query operator was evaluated at runtime - move this to expansion of hte operator at planning time using the simplify function.
2024-03-01 17:24:28 +03:00
Zinan Ren 🐾 27d920e43e Merged PR 1281181: [Vector Search] Support filter schema in 1.12-1
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
UDF

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
To make preview feature "filter" works in 1.12 schema
2024-03-01 17:24:28 +03:00
Parag Jain 7bb916a093 Merged PR 1251259: Run backend test against citus 12 and removed existing change_stream with backward compat
This PR has following changes :
1.removed change_description column from mongo_data.document table because from citus 11.2 there was a [fix](https://github.com/citusdata/citus/commit/27e867afbc72180fb04b618293af5b3a944b6cd4) which results into [behavior mismatch in mongo_api_v1.collection function](https://msdata.visualstudio.com/CosmosDB/_workitems/edit/2942338). To handle this removed change_description column from mongo_data.document table.
2. modified backend pipeline to run backend test against citus 12 container image as well.
3. removed watch_collection and change_feed sql function as it is no longer needed in 1.13 binary.

subsequent PR :
Modify backend_test and deployment_build_pipeline  to run jstest and cSharpe test aginst citus 12.
Change Naming Convention of CosmosDbDrop and deployArtifact for citus-11 and citus-12

Related work items: #2902318, #2942338
2024-02-23 14:49:18 +03:00
Vinod Sridharan 37744ff32a Merged PR 1279725: [Flex] Enable Data plane metrics emission from the Extension
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Devops

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No(ish)

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Add function to emit data plane metrics from teh extension. Add a cron job to publish that every min.
Register that function as a cron job in flex.

This first part publishes the FeatureCounter data into warm path config as so:
![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1279725/attachments/image.png)

Subsequent changes will be made to add more metrics into the emission path.
2024-02-23 14:49:18 +03:00
Vinod Sridharan b3e28caf50 Merged PR 1280370: [Performance] Improve performance of point reads
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Performance

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
For point reads that go into the B-tree index, we were also evaluating the filter `docid @= { _id : value}` again even though those were equivalent.

Remove the extraneous filter to improve point read performance.
2024-02-23 14:49:18 +03:00
Murat Tuncer f0303504d7 Merged PR 1280158: Fix pg_ctl path for heliodb start/stop operations
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
DevOps
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Fix pg_ctl path for heliodb start/stop operations
2024-02-23 14:49:18 +03:00
Mehmet Yilmaz 1224a287d6 Merged PR 1269280: [OSS] Move auth_scram functions to OSS
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move auth_scram functions to OSS
2024-02-23 14:49:18 +03:00
Ujjwal Agrawal 58ccf507d4 Merged PR 1235816: $centerSphere geospatial shape operator impl: Part 1 support for legacy coordinates and GeoJson points
As finalized in the design review on 10th January, `st_dwithin` shall be used for $center and $centerSphere
For index pushdown `st_dwithin` uses `st_expand` method to calculate the bounding box for given point, so we're using `st_expand` directly at the time of index pushdown, and `st_dwithin` at runtime.
This is part 1 of 2 that implements that change - this returns some false positives as st_dwithin returns true for polygons of which at least 1 point lies within the specified distance. It returns true even if all other points lie outside.
The next part will handle checking all points for distance in runtime.

**Brief summary of design discussion -**
$center used ST_BUFFER to create a buffer area, but using the same for geography has a few drawbacks -
1. If the buffer becomes bigger than a UTM zone or it crosses **the international dateline** it results in undefined behaviour. For example, the above query returns false if we increase the buffer radius to **12000000 (12000 km)** as it crosses the dateline at **(180 90)**.
Hence the query behavior looks like this -

```
[direct: mongos] db> db.geoquerytest.find({"a.b": {$geoWithin: {$centerSphere: [[0, 0], 1.57]}}})   //100013.6 km
[
  { _id: 1, a: { b: [ 10, 10 ] } },
  { _id: 2, a: { b: { long: Long("20"), lat: 20 } } },
  {
    _id: 3,
    a: [
      { b: { long: 25, lat: 25 } },
      [ 30, Decimal128("30") ],
      [ 35, 35 ]
    ]
  },
  { _id: 5, a: { b: { x: Long("12"), y: 12 } } }
]
[direct: mongos] db> db.geoquerytest.find({"a.b": {$geoWithin: {$centerSphere: [[0, 0], 1.6]}}})    //10205 km

```

2. The circle is **imperfect**. It has 8 segments in each quadrant (by default) which may result in boundary cases like below failing -

`SELECT ST_Covers(ST_BUFFER('Point(0 0)'::geography, 630000), 'Point(4.9757 2.66966)'::geography);` returns **false**.

Similar test on native mongo -
```
test> db.coll4.find({"a": {$geoWithin: {$centerSphere: [[0, 0], 0.0987]}}}) //629.5 km
[
  {
    _id: ObjectId("658304b574dc0e47e5cab903"),
    a: { type: 'Point', coordinates: [ 4.9757, 2.66966 ] }
  }
]
```

3. ST_Covers doesn't work well with polygons with holes. So this returns false -

```
SELECT ST_Covers(ST_BUFFER('Point(0 0)'::geography, 50000), 'MultiPolygon(((0.1 0.2, 0.1 0.3, 0.2 0.3, 0.2 0.2, 0.1 0.2), (0.15 0.22, 0.15 0.25, 0.18 0.25, 0.18 0.22, 0.15 0.22)))'::geography);
```

It was decided that ST_DWITHIN be used to overcome these limitations.

There's a bug in Explain behavior where it has a recheck condition even though recheck is set to false, it'll be tracked with this- https://msdata.visualstudio.com/CosmosDB/_workitems/edit/2968574

Related work items: #2903014, #2950457
2024-02-23 14:49:18 +03:00
Abhishek Johri 8bccdf75a9 Merged PR 1275797: Minor Bug Fix Current Op
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
String length for dropDatabase was wrong in Current Op
2024-02-23 14:49:18 +03:00
Vinod Sridharan bfa1cf4344 Merged PR 1275970: [Truncation] Implement top level object truncation
### Does this PR have any customer impact?
No(ish)

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/template.md))
N/A

### Description
Implement truncation for documents + add testing.
Along with this fix a bug in array truncation.

Related work items: #2964175
2024-02-23 14:49:18 +03:00
Vinod Sridharan 3101112245 Merged PR 1262530: Helio API Gateway changes
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move Gateway to use the Helio_API schema for available top level methods.
2024-02-23 14:49:18 +03:00
Tanvi Bhandari cb3d803738 Merged PR 1274919: Cancel CreateIndex via DropIndex fails with Seg-fault
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
BugFix

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Fix Segmentation Fault during dropping the long running create index request

### Description
**[Index Build Background] [During TIP in 1.13]**
Steps:
1. Trigger CreateIndex from one session
2. Trigger DropIndex for the same index from another session
3. It was causing Seg-fault because comment set by DropIndexes while marking index Skippable was empty.
4. Also, we should cancel the CREATE INDEX CONCURRENTLY before triggering DROP INDEX CONCURRENTLY

Related work items: #2961363
2024-02-16 13:49:10 +03:00
Murat Tuncer b37796ce4a Merged PR 1275221: Change core count detection logic
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
DevOps

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Count "processor" instead of "core id" to determine
number of cpu cores available
2024-02-16 13:49:10 +03:00
Jayanta Mondal 73b292ef9d Merged PR 1275225: [Testing] Changing test display name for better discovery
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Code Comment, Test Name change
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

For parameterized tests Azure devops only shows the custom display name of the tests and does not append the actual name of the test method. So, adding that in this PR, for better discoverability.

![image.png](https://msdata.visualstudio.com/ba574a88-a171-48e0-8fcb-5fef6d23739c/_apis/git/repositories/501a5e7e-ffdc-4d1e-a5e6-910f73c6eb9a/pullRequests/1275225/attachments/image.png)
2024-02-16 13:49:10 +03:00
Mehmet Yilmaz e329534b27 Merged PR 1265532: [OSS] Refactor some pgmongo references in OSS
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Refactor some pgmongo references in OSS
2024-02-16 13:49:10 +03:00
Ayush Saluja 96408265a7 Merged PR 1248348: [pgmongo] $min $max projection stage operator
This is for supporting the $min, $max in the projection stage.

Related work items: #2954640
2024-02-16 13:49:10 +03:00
Jayanta Mondal 8016914aea Merged PR 1271425: $in query rewrite
### Does this PR have any customer impact?
Limited, the feature is behind a feature flag.

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature/Perf.

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Queries of the form

```
SELECT document FROM bson_aggregation_find('db', '{ "find": "in_opt_tests", "filter": { "accid":1, "vid": 1, "val": { "$in": [1, 3]} } }');
```

Will be **effectively** rewritten to

```
SELECT document FROM bson_aggregation_find('db', '{ "find": "in_opt_tests", "filter": { "accid":1, "vid": 1, "val": { "$in": [1, 3]} } }');

```

However, we don't intercept the mongo query and rewrite it. As the `$in` can be used in different query path. Instead, we do the rewrite after the query plan generation, and specifically, when `$in` is shows up a condition in the Index Path. While `$in` today is pushed down to the index, it's not performant.  However, if we rewrite the `$in` to be a `OR` of a set of `$eq` clause, that becomes peformant, as `RUM fast scan` is enabled for `$eq` but not yet for `$in`.  **For, 100K records, the latency goes down from `80ms` to ~`3ms` on devbox.**

**_Explain before rewrite:_**

```
               ->  Bitmap Index Scan on val_accid_vid  (cost=0.00..0.00 rows=1 width=0) (actual time=23.937..23.937 rows=7 loops=1)
                      Index Cond: Index Cond: ((document OPERATOR(mongo_catalog.@*=) '[{ "val" : { "$numberInt" : "1" } }, { "val" : { "$numberInt" : "3" } }]'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson))*/

```

**_Explain after rewrite:_**
```

Custom Scan (Citus Adaptive)
   Task Count: 1
   Tasks Shown: All
   ->  Task
         Node: host=localhost port=58080 dbname=regression
         ->  Bitmap Heap Scan on documents_33000_330023 collection
               Recheck Cond: (((document OPERATOR(mongo_catalog.@=) '{ "val" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson)) OR ((document OPERATOR(mongo_catalog.@=) '{ "val" : { "$numberInt" : "3" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "accid" : { "$numberInt" : "1" } }'::mongo_catalog.bson) AND (document OPERATOR(mongo_catalog.@=) '{ "vid" : { "$numberInt" : "1" } }'::mongo_catalog.bson)))
               Filter: ((document OPERATOR(mongo_catalog.@*=) '{ "val" : [ { "$numberInt" : "1" }, { "$numberInt" : "3" } ] }'::mongo_catalog.bson) AND (shard_key_value = '4322365043291501017'::bigint))
               ->  BitmapOr
                     ->  Bitmap Index Scan on val_accid_vid
       ...
2024-02-16 13:49:10 +03:00
Vinod Sridharan 82ce7d16ac Merged PR 1274312: [Index] Improve ComparePartial performance
### Does this PR have any customer impact?
Yes

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
When doing compare partial today, the index layer does a tuple store put/get/sort. This means it's sensitive to the tuple size which today is a full scan item. In the case where useAlternativeOrder and useCurKey is false (no sorts) we don't need as much information. Make the tuple store smaller in these cases.

Based on testing on simple scenarios of $exists of a few million documents, we see it go from ~2s to 1.4s for a compare partial query.
2024-02-16 13:49:10 +03:00
Ayush Saluja 075acbf3a0 Merged PR 1267038: [pgmongo]Aggregation Operator BinarySize
### Does this PR have any customer impact?
Yes, Support for new

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Adding support for  $binarySize operator in data size.
https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/

Related work items: #2019187
2024-02-16 13:49:10 +03:00
Santiago Fernandez Madero be023ae2a5 Merged PR 1273968: Add oss md files
Add oss md files
2024-02-14 11:28:20 +03:00
Deepak Bisht bf9ef6e59e Merged PR 1247537: [Pgmong][Geospatial] - 2d segmentize takes a huge time for large query boxes.
So in the earlier PR to segmentize the given geography query with 500km of segment length we were deriving the segment length for 2d using this strategy:

1- 2d distance of (0,0 to 1,1) => 1.41
2- 2dsphere distance of (0, 0 to 1, 1) =>156.9Km

So the segment length for 2d becomes => ( 500 ) / (157/1.41) -> ~4.41

But this is only true if the 2d bounds are similar to earth coordinates and will start taking time when query boxes are bigger than earth bounds.

So in this PR I approximately scale up the segment length based on the size of the 2d region. So that segmentize should work relative to the given size

Related work items: #2894618
2024-02-14 11:28:20 +03:00
Vinod Sridharan 44678d8185 Merged PR 1272971: [Explain] More Explain Improvements based on investigations & TTL Flag
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Diagnostics

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No

### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Add option for BUFFERS & TIMING on the explain.
Also add RowsRemovedByIndexRecheck and RowsRemovedByFilter as top level.

For TTL, always set forceUseIndexIfAvailable
2024-02-14 11:28:20 +03:00
Vinod Sridharan d57e9aa236 Merged PR 1271766: Improve performance of the $lt operator
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Perf
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
Improve $lt performance when having mixed types
### Description
In scenarios where $lt was applied to a field that had "nulls" in it, we would start with MinKey and scan up - which would require passing through all the null valued entries.

Do a best effort to pick a lower bound that is better than MinKey when available.
2024-02-14 11:28:20 +03:00