diff --git a/apps/docs/content/guides/ai/vector-indexes.mdx b/apps/docs/content/guides/ai/vector-indexes.mdx index 93b4d303e7394..99f1d8823b1f0 100644 --- a/apps/docs/content/guides/ai/vector-indexes.mdx +++ b/apps/docs/content/guides/ai/vector-indexes.mdx @@ -26,7 +26,15 @@ Indexes can be used to improve performance of nearest neighbor search using vari | `<#>` | negative inner product | `vector_ip_ops` | | `<=>` | cosine distance | `vector_cosine_ops` | -Currently vectors with up to 2,000 dimensions can be indexed. +For pgvector versions 0.7.0 and above, it's possible to create indexes on vectors with the following maximum dimensions: + +- vector: up to 2,000 dimensions +- halfvec: up to 4,000 dimensions +- bit: up to 64,000 dimensions + +You can check your current pgvector version by running: `SELECT * FROM pg_extension WHERE extname = 'vector';` or by navigating to the [Extensions](/dashboard/project/_/database/extensions) tab in your Supabase project dashboard. + +If you are on an earlier version of pgvector, you should [upgrade your project here](/dashboard/project/_/settings/infrastructure). ## Resources diff --git a/apps/docs/content/guides/ai/vector-indexes/hnsw-indexes.mdx b/apps/docs/content/guides/ai/vector-indexes/hnsw-indexes.mdx index eb7d09ac96fe7..0fba3bbb29635 100644 --- a/apps/docs/content/guides/ai/vector-indexes/hnsw-indexes.mdx +++ b/apps/docs/content/guides/ai/vector-indexes/hnsw-indexes.mdx @@ -37,7 +37,30 @@ create index on items using hnsw (column_name vector_ip_ops); create index on items using hnsw (column_name vector_cosine_ops); ``` -Currently vectors with up to 2,000 dimensions can be indexed. +For pgvector versions 0.7.0 and above, it's possible to create indexes on vectors with the following maximum dimensions: + +- vector: up to 2,000 dimensions +- halfvec: up to 4,000 dimensions +- bit: up to 64,000 dimensions + +You can check your current pgvector version by running: `SELECT * FROM pg_extension WHERE extname = 'vector';` or by navigating to the [Extensions](/dashboard/project/_/database/extensions) tab in your Supabase project dashboard. + +If you are on an earlier version of pgvector, you should [upgrade your project here](/dashboard/project/_/settings/infrastructure). + +## Example with high-dimensional vectors + +For vectors with more than 2,000 dimensions, you can use the `halfvec` type to create indexes. Here's an example with 3,072 dimensions: + +```sql +CREATE TABLE documents ( + id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + content text, + embedding vector(3072) +); + +CREATE INDEX ON documents + USING hnsw ((embedding::halfvec(3072)) halfvec_cosine_ops); +``` ## How does HNSW work? diff --git a/apps/docs/content/guides/platform/billing-faq.mdx b/apps/docs/content/guides/platform/billing-faq.mdx index aed16ece33e4b..05373aaf5a488 100644 --- a/apps/docs/content/guides/platform/billing-faq.mdx +++ b/apps/docs/content/guides/platform/billing-faq.mdx @@ -68,7 +68,7 @@ Read more about [Compute usage](/docs/guides/platform/manage-your-usage/compute) Egress refers to the total bandwidth (network traffic) quota available to each organization. This quota can be utilized for various purposes such as Storage, Realtime, Auth, Functions, Supavisor, Log Drains and Database. Each plan includes a specific egress quota, and any additional usage beyond that quota is billed accordingly. -We differentiate between cached (served via our CDN from cache hits) and uncached egress and give quotas for each type and have varying pricing (cached egress is cheaper). +We differentiate between cached (served via our CDN from cache hits) and uncached egress and give quotas for each type and have varying pricing (cached egress is cheaper). Cached egress only applies to Storage. Read more about [Egress usage](/docs/guides/platform/manage-your-usage/egress). diff --git a/apps/docs/content/troubleshooting/all-about-supabase-egress-a_Sg_e.mdx b/apps/docs/content/troubleshooting/all-about-supabase-egress-a_Sg_e.mdx index 00bd84d90a899..ba61fc9fa979a 100644 --- a/apps/docs/content/troubleshooting/all-about-supabase-egress-a_Sg_e.mdx +++ b/apps/docs/content/troubleshooting/all-about-supabase-egress-a_Sg_e.mdx @@ -35,6 +35,6 @@ While pointing out the exact cause for egress may not be straightforward, there **Cached vs uncached egress** -We differentiate between cached and uncached egress. Cached egress refers to egress that is served via our CDN and hits the cache. Uncached egress, on the other hand, refers to egress that is not served from the cache and requires a fresh request to the origin server. +We differentiate between cached and uncached egress. Cached egress, which only applies to Supabase Storage, refers to egress that is served via our CDN and hits the cache. Uncached egress, on the other hand, refers to egress that is not served from the cache and requires a fresh request to the origin server. Your plan includes a quota for both cached and uncached egress and these are independent. Cached egress is also cheaper in case you exceed your quota. diff --git a/apps/studio/components/grid/MsSqlValidation.tsx b/apps/studio/components/grid/MsSqlValidation.tsx new file mode 100644 index 0000000000000..b6951f4c514dd --- /dev/null +++ b/apps/studio/components/grid/MsSqlValidation.tsx @@ -0,0 +1,77 @@ +import { isMsSqlForeignTable, type Entity } from 'data/table-editor/table-editor-types' +import type { ComponentType, ReactNode } from 'react' + +import { Admonition } from 'ui-patterns' +import type { Filter, Sort } from './types' + +type ValidateMsSqlSortingParams = { + filters: Filter[] + sorts: Sort[] + table: Entity +} + +type MsSqlWarning = 'ConflictingSort' | 'NoValidSortPossible' + +/** + * There is an edge case with the Postgres query planner and MS SQL foreign + * tables, where the Postgres query planner will drop sort clauses that are + * redundant with filters, resulting in invalid MS SQL syntax. We want to + * detect any conflicting or impossible sorts on filtered columns when the + * table is an MS SQL foreign table, and warn the user. + */ +export const validateMsSqlSorting = ({ + filters, + sorts, + table, +}: ValidateMsSqlSortingParams): + | { warning: MsSqlWarning; Component: ComponentType } + | { warning: null } => { + const isMsSql = isMsSqlForeignTable(table) + if (!isMsSql) return { warning: null } + + const equalityFilterColumns = new Set( + filters + .filter((filter) => filter.operator === '=' || filter.operator === 'is') + .map((filter) => filter.column) + ) + + const conflictingSort = + sorts.length > 0 && sorts.every((sort) => equalityFilterColumns.has(sort.column)) + const showMsSqlSortWarning = equalityFilterColumns.size > 0 && !!conflictingSort + if (showMsSqlSortWarning) + return { warning: 'ConflictingSort', Component: MsSqlSortWarningAdmonition } + + const noSortColumnsRemaining = + table.columns.length > 0 && + table.columns.every((col) => col.data_type === 'json' || equalityFilterColumns.has(col.name)) + const showMsSqlNoValidSortWarning = filters.length > 0 && noSortColumnsRemaining + if (showMsSqlNoValidSortWarning) + return { warning: 'NoValidSortPossible', Component: MsSqlNoValidSortAdmonition } + + return { warning: null } +} + +type MsSqlAdmonitionProps = { + title: string + children: string +} + +const MsSqlAdmonition = ({ title, children }: MsSqlAdmonitionProps): ReactNode => ( +