Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Support customIndex for MySQL #3789

Open
1 task done
dengfuping opened this issue Dec 17, 2024 · 1 comment
Open
1 task done

[FEATURE]: Support customIndex for MySQL #3789

dengfuping opened this issue Dec 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dengfuping
Copy link

dengfuping commented Dec 17, 2024

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Background

MySQL and MySQL ecosystem exists all kinds of create index scene‌s as below.

  • create normal index:
CREATE INDEX idx_name on users(name) ;
CREATE INDEX idx_name on users(name) using hash;
CREATE UNIQUE INDEX idx_id on users(id);
  • create spatial index:
CREATE SPATIAL INDEX idx_geom on users(geom);
  • create fulltext index:
CREATE FULLTEXT INDEX idx_doc(doc) WITH PARSER NGRAM;
  • create vector index for MySQL:
CREATE VECTOR INDEX idx_embedding ON users(embedding) SECONDARY_ENGINE_ATTRIBUTE=\'{"type":"spann", "distance":"cosine"}\';
  • create vector index for OceanBase (a MySQL-like database but not 100% compatible):
CREATE VECTOR INDEX idx_embedding ON users(embedding) WITH (distance=L2, type=hnsw);

Proposal

Current Dizzle index couldn't implement these demands. So I proposal to add customIndex API to define raw create index statement.

const users = mysqlTable(
    "users",
    {
      id: bigint({ mode: "bigint" }).autoincrement().primaryKey(),
      name: varchar({ length: 255 }).notNull(),
      embedding: vector("embedding", { length: 3 }),
    },
    () => {
      return {
        idx_embedding: customIndex({
	  name: 'idx_embedding',
	  raw: 'CREATE VECTOR INDEX idx_embedding ON users(embedding) SECONDARY_ENGINE_ATTRIBUTE=\'{"type":"spann", "distance":"cosine"}\';',
	}),
        idx_fulltext: customIndex({
	  name: 'idx_fulltext',
	  raw: 'CREATE FULLTEXT INDEX idx_doc(doc) WITH PARSER NGRAM;',
	}),
      };
    }
  )
@dengfuping dengfuping added the enhancement New feature or request label Dec 17, 2024
@dengfuping
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant