Skip to content

workload/kv: add --secondary-index flag#31573

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/kvSecond
Oct 24, 2018
Merged

workload/kv: add --secondary-index flag#31573
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/kvSecond

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Oct 18, 2018

The flag instructs schema initialization to add a secondary index
on the v column. This has been useful for experimenting with the
perf impact of secondary indexes.

Release note: None

@nvb nvb requested a review from a-robinson October 18, 2018 05:23
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

},
PostLoad: func(sqlDB *gosql.DB) error {
if w.secondaryIndex {
_, err := sqlDB.Exec(`CREATE INDEX IF NOT EXISTS v_idx ON kv (v)`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this going to be backfilled in the background? If so, the impact of that will be pretty nondeterministic. Maybe that doesn't matter now, but perhaps call it out on the flag.

Copy link
Copy Markdown
Contributor

@a-robinson a-robinson left a comment

Choose a reason for hiding this comment

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

LGTM, although I'm also curious about the fact that creating the index is done PostLoad rather than PreLoad. I assume it's just meant to rely on the fact that we don't use fixtures for kv?

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Oct 18, 2018

Both questions here are good and I had similar ones while making the change. Putting this in PostLoad was inspired by workload/tpcc. @danhhz is that how you would expect this to work? An alternative would be to change the workload.Table.Schema field based on the flag.

Copy link
Copy Markdown
Contributor

@danhhz danhhz left a comment

Choose a reason for hiding this comment

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

I would advocate for changing the schema based on the flag so it will work better with fixtures. tpcc adds foreign keys in PostLoad, but it's very careful to make the indexes needed for those foreign keys ahead of time in the schema (which means they're in the fixtures).

},
PostLoad: func(sqlDB *gosql.DB) error {
if w.secondaryIndex {
_, err := sqlDB.Exec(`CREATE INDEX IF NOT EXISTS v_idx ON kv (v)`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if you keep this as PostLoad, it should be marked as a runtime-only flag, since it doesn't affect fixtures here

The flag instructs schema initialization to add a secondary index
on the `v` column. This has been useful for experimenting with the
perf impact of secondary indexes.

Release note: None
@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Oct 24, 2018

I would advocate for changing the schema based on the flag so it will work better with fixtures.

Done. Looks much better.

@nvb nvb force-pushed the nvanbenschoten/kvSecond branch from 76a68f5 to 9c7b556 Compare October 24, 2018 18:27
@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Oct 24, 2018

TFTRs.

bors r+

Copy link
Copy Markdown
Contributor

@a-robinson a-robinson left a comment

Choose a reason for hiding this comment

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

Nice, LGTM.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 24, 2018

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Oct 24, 2018
31573: workload/kv: add --secondary-index flag r=nvanbenschoten a=nvanbenschoten

The flag instructs schema initialization to add a secondary index
on the `v` column. This has been useful for experimenting with the
perf impact of secondary indexes.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 24, 2018

Build succeeded

@craig craig bot merged commit 9c7b556 into cockroachdb:master Oct 24, 2018
@nvb nvb deleted the nvanbenschoten/kvSecond branch October 28, 2018 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants