Skip to content

Conversation

@disq
Copy link
Member

@disq disq commented Apr 12, 2023

Fixes #9614

Checking with db.system.profile.find().limit(5).pretty() after db.setProfilingLevel(2) I don't see any COLLSCANs. We're not adding indexes for _cq_source_name,_cq_sync_time so DeleteStale is probably still slow.

Verified with db.system.profile.find({ "planSummary": "COLLSCAN", "ns": { "$ne": "mdb.system.profile" } }) as well.

@disq disq requested review from a team and yevgenypats and removed request for a team April 12, 2023 11:32
@cq-bot cq-bot added the mongodb label Apr 12, 2023
@disq disq marked this pull request as draft April 12, 2023 11:56
@disq disq marked this pull request as ready for review April 12, 2023 12:08
if c.spec.WriteMode == specs.WriteModeOverwriteDeleteStale {
delIndexName := "cq_del"
indexes = append(indexes, mongo.IndexModel{
Keys: bson.D{{Key: schema.CqSourceNameColumn.Name, Value: 1}, {Key: schema.CqSyncTimeColumn.Name, Value: 1}},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the values here.

func (c *Client) migrateTable(ctx context.Context, table *schema.Table) error {
indexModels := c.getIndexTemplates(table)
for _, mdl := range indexModels {
res, err := c.client.Database(c.pluginSpec.Database).Collection(table.Name).Indexes().CreateOne(ctx, mdl)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's CreateMany as well but it would get complicated to do the error handling afterwards. It fails on the first error and you'd have to do re-runs to check/handle all.

return false
}

// This is either "Index already exists with a different name: %s" error or due to uniqueness change
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they want non-unique indexes in cq_pk, they can have it?

@disq disq added the automerge Automatically merge once required checks pass label Apr 17, 2023
@kodiakhq kodiakhq bot merged commit 9e20642 into cloudquery:main Apr 17, 2023
@disq disq deleted the feat/mongodb-dest-create-indexes branch April 17, 2023 08:39
kodiakhq bot pushed a commit that referenced this pull request Apr 25, 2023
🤖 I have created a release *beep* *boop*
---


## [2.0.0](plugins-destination-mongodb-v1.1.5...plugins-destination-mongodb-v2.0.0) (2023-04-25)


### ⚠ BREAKING CHANGES

* This release introduces an internal change to our type system to use [Apache Arrow](https://arrow.apache.org/). This should not have any visible breaking changes, however due to the size of the change we are introducing it under a major version bump to communicate that it might have some bugs that we weren't able to catch during our internal tests. If you encounter an issue during the upgrade, please submit a [bug report](https://github.com/cloudquery/cloudquery/issues/new/choose).

### Features

* **mongodb:** Create unique indexes for PKs ([#9851](#9851)) ([9e20642](9e20642))
* Update to use [Apache Arrow](https://arrow.apache.org/) type system ([9e74b76](9e74b76))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.45.0 ([#9863](#9863)) ([2799d62](2799d62))
* **deps:** Update module github.com/cloudquery/plugin-sdk/v2 to v2.4.0 ([#10278](#10278)) ([a0a713e](a0a713e))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MongoDB destination plugin does not create indexes for primary keys

3 participants