mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Merge branch 'master' into docs-rum
This commit is contained in:
commit
4e4720ecaa
9 files changed
+177
-42
No files matched your search
@@ -404,6 +404,11 @@ export const database = {
|
||||
url: '/guides/database/extensions/pgnet',
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
name: 'pg_repack: Storage Optimization',
|
||||
url: '/guides/database/extensions/pgrepack',
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
name: 'PostGIS: Geo queries',
|
||||
url: '/guides/database/extensions/postgis',
|
||||
|
||||
@@ -488,5 +488,12 @@
|
||||
"default_version": "1.3.13",
|
||||
"installed_version": "1.3.13",
|
||||
"comment": "GIN-like index for text search"
|
||||
},
|
||||
{
|
||||
"name": "pg_repack",
|
||||
"schema": "extensions",
|
||||
"default_version": "1.4.8",
|
||||
"installed_version": "1.4.8",
|
||||
"comment": "optimize physical storage and remove bloat from tables and indexes"
|
||||
}
|
||||
]
|
||||
@@ -282,7 +282,7 @@ type SupabaseContext = {
|
||||
supabase: SupabaseClient<Database>
|
||||
}
|
||||
|
||||
const Context = createContext<SupabaseContext>()
|
||||
const Context = createContext<SupabaseContext | undefined>(undefined)
|
||||
|
||||
export default function SupabaseProvider({ children }: { children: React.ReactNode }) {
|
||||
const [supabase] = useState(() => createClient())
|
||||
@@ -294,7 +294,13 @@ export default function SupabaseProvider({ children }: { children: React.ReactNo
|
||||
)
|
||||
}
|
||||
|
||||
export const useSupabase = () => useContext(Context)
|
||||
export const useSupabase = () => {
|
||||
if (context === undefined) {
|
||||
throw new Error("useSupabase must be used inside SupabaseProvider");
|
||||
}
|
||||
|
||||
return useContext(Context)
|
||||
}
|
||||
```
|
||||
|
||||
> TypeScript types can be [generated with the Supabase CLI](https://supabase.com/docs/reference/javascript/typescript-support) and passed to `createBrowserSupabaseClient` to add type support to the Supabase client.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
|
||||
export const meta = {
|
||||
title: 'pg_repack: Physical storage optimization and maintenance',
|
||||
description:
|
||||
'A tool to remove bloat from tables and indexes and optimize physical data order and physical storage',
|
||||
}
|
||||
|
||||
[pg_repack](https://github.com/reorg/pg_repack) is a PostgreSQL extension to remove bloat from tables and indexes, and optionally restore the physical order of clustered indexes. Unlike CLUSTER and VACUUM FULL it works online, without holding an exclusive lock on the processed tables during processing. pg_repack is efficient to boot, with performance comparable to using CLUSTER directly.
|
||||
|
||||
pg_repack provides the following methods to optimize physical storage:
|
||||
|
||||
- Online CLUSTER: ordering table data by cluster index in a non-blocking way
|
||||
- Ordering table data by specified columns
|
||||
- Online VACUUM FULL: packing rows only in a non-blocking way
|
||||
- Rebuild or relocate only the indexes of a table
|
||||
|
||||
## Requirements
|
||||
|
||||
- Only superusers can use the utility.
|
||||
- Target table must have a PRIMARY KEY, or a UNIQUE total index on a NOT NULL column.
|
||||
- Performing a full-table repack requires free disk space about twice as large as the target table and its indexes.
|
||||
|
||||
## Usage
|
||||
|
||||
### Enable the extension
|
||||
|
||||
Get started with pg_repack by enabling the extension in the Supabase Dashboard.
|
||||
|
||||
<Tabs
|
||||
scrollable
|
||||
size="small"
|
||||
type="underlined"
|
||||
defaultActiveId="dashboard"
|
||||
>
|
||||
<TabPanel id="dashboard" label="Dashboard">
|
||||
|
||||
1. Go to the [Database](https://app.supabase.com/project/_/database/tables) page in the Dashboard.
|
||||
2. Click on **Extensions** in the sidebar.
|
||||
3. Search for "pg_repack" and enable the extension.
|
||||
|
||||
</TabPanel>
|
||||
<TabPanel id="sql" label="SQL">
|
||||
|
||||
```sql
|
||||
-- Example: enable the "pg_repack" extension
|
||||
create extension pg_repack with schema extensions;
|
||||
|
||||
-- Example: disable the "pg_repack" extension
|
||||
drop extension if exists pg_repack;
|
||||
```
|
||||
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
|
||||
### Syntax
|
||||
|
||||
```sh
|
||||
pg_repack [OPTION]... [DBNAME]
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
It's useful for performance to support tables data ordered on disk and physically remove deleted data that remain
|
||||
otherwise.
|
||||
|
||||
Perform an online CLUSTER of all the clustered tables in the database `db`, and perform an online `VACUUM FULL` of all the non-clustered tables:
|
||||
|
||||
```sh
|
||||
pg_repack db
|
||||
```
|
||||
|
||||
Perform an online `VACUUM FULL` on the tables `table1` and `table2` in the database `db` (an eventual cluster index is ignored):
|
||||
|
||||
```sh
|
||||
pg_repack --no-order --table table1 --table table2 db
|
||||
```
|
||||
|
||||
Moving indexes to a tablespace on a faster volume increases performance of `SELECT` queries using these indexes
|
||||
drastically. `INSERT`s and `UPDATE`s of a table with indexes on a fast volume are also faster. This is very useful
|
||||
when the fast volume is small and can not accommodate all tables, as indexes are much smaller than tables.
|
||||
|
||||
Move all indexes of table `table1` to tablespace `tbs`:
|
||||
|
||||
```sh
|
||||
pg_repack -d db --table table1 --only-indexes --tablespace tbs
|
||||
```
|
||||
|
||||
Move the specified index `idx` to tablespace `tbs`:
|
||||
|
||||
```sh
|
||||
pg_repack -d db --index idx --tablespace tbs
|
||||
```
|
||||
|
||||
See the [official pg_repack documentation](https://reorg.github.io/pg_repack/) for the full list of options.
|
||||
|
||||
## Restrictions
|
||||
|
||||
- pg_repack cannot reorganize temp tables.
|
||||
- pg_repack cannot cluster tables by GiST indexes.
|
||||
- You cannot perform DDL commands of the target tables except VACUUM or ANALYZE while pg_repack is working.
|
||||
pg_repack holds an ACCESS SHARE lock on the target table to enforce this restriction.
|
||||
|
||||
## Resources
|
||||
|
||||
- [Official pg_repack documentation](https://reorg.github.io/pg_repack/)
|
||||
|
||||
export const Page = ({ children }) => <Layout meta={meta} children={children} />
|
||||
|
||||
export default Page
|
||||
@@ -32,8 +32,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
|
||||
PROJECT_ID: zdtdtxajzydjqzuktnqx
|
||||
SUPABASE_ACCESS_TOKEN: YOUR_SUPABASE_ACCESS_TOKEN
|
||||
PROJECT_ID: YOUR_SUPABASE_PROJECT_ID
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
studio:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: studio/Dockerfile
|
||||
target: dev
|
||||
ports:
|
||||
- 8082:8082
|
||||
mail:
|
||||
container_name: supabase-mail
|
||||
image: inbucket/inbucket:3.0.3
|
||||
|
||||
+26
-37
@@ -9,57 +9,46 @@
|
||||
# docker builder prune
|
||||
|
||||
FROM node:16-slim as base
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN npm i -g turbo
|
||||
|
||||
# Calculate if dependencies are outdated
|
||||
FROM base as turbo
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Prune unneeded dependencies with turbo (from apps/ for example)
|
||||
RUN turbo prune --scope=studio --docker
|
||||
FROM base as turbo
|
||||
COPY . .
|
||||
# Upstream bug: https://github.com/vercel/turbo/issues/3570
|
||||
RUN npx turbo@1.7.0 prune --scope=studio --docker
|
||||
|
||||
# Install dev dependencies (only if needed)
|
||||
FROM base as deps
|
||||
WORKDIR /app
|
||||
COPY --from=turbo /app/out/json/ .
|
||||
COPY --from=turbo /app/out/json ./
|
||||
COPY --from=turbo /app/out/package-lock.json ./
|
||||
RUN npm clean-install && npm cache clean --force
|
||||
# Install additional dependencies for arm64 build (required by bufferutil)
|
||||
ARG TARGETARCH
|
||||
RUN if [ "$TARGETARCH" = "arm64" ]; then \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*; fi
|
||||
# No need to clean cache because production uses standalone build
|
||||
RUN npm clean-install
|
||||
|
||||
FROM deps as deps-prod
|
||||
RUN npm prune --production
|
||||
# Remove packages dependencies (not needed in production)
|
||||
RUN rm -rf /app/packages
|
||||
|
||||
# builder contains dependencies and source code not compiled
|
||||
FROM deps as builder
|
||||
WORKDIR /app
|
||||
# dev contains dependencies and source code not compiled
|
||||
FROM deps as dev
|
||||
COPY --from=turbo /app/out/full ./
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
FROM builder as dev
|
||||
EXPOSE 8082
|
||||
CMD ["npx", "turbo", "run", "dev", "--filter=studio"]
|
||||
CMD ["npm", "run", "dev:studio"]
|
||||
|
||||
# Compile NextJS
|
||||
FROM builder as productionprep
|
||||
WORKDIR /app
|
||||
RUN npx turbo run build --scope=studio --include-dependencies --no-deps \
|
||||
&& rm -rf ./studio/.next/cache/webpack
|
||||
FROM dev as builder
|
||||
RUN npx turbo run build --scope=studio --include-dependencies --no-deps
|
||||
|
||||
# Copy only compiled code and dependencies
|
||||
FROM node:16-slim as production
|
||||
# Copy package(s).json and package-lock.json
|
||||
COPY --from=turbo /app/out/json /app
|
||||
# Copy all dependencies for production
|
||||
COPY --from=deps-prod /app /app
|
||||
# Copy necessary files
|
||||
COPY --from=turbo /app/out/full/studio /app/studio
|
||||
COPY --from=productionprep /app/studio/.next /app/studio/.next
|
||||
WORKDIR /app/studio
|
||||
FROM base as production
|
||||
COPY --from=builder /app/studio/public ./studio/public
|
||||
COPY --from=builder /app/studio/.next/standalone/app ./
|
||||
COPY --from=builder /app/studio/.next/static ./studio/.next/static
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD node -e "require('http').get('http://localhost:3000/api/profile', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"
|
||||
CMD ["npm", "run", "start"]
|
||||
CMD ["node", "studio/server.js"]
|
||||
@@ -7,6 +7,7 @@ import BaseLayout from '../'
|
||||
import Error from 'components/ui/Error'
|
||||
import ProductMenu from 'components/ui/ProductMenu'
|
||||
import { generateDatabaseMenu } from './DatabaseMenu.utils'
|
||||
import { IS_PLATFORM } from 'lib/constants'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
@@ -34,7 +35,9 @@ const DatabaseLayout: FC<Props> = ({ title, children }) => {
|
||||
meta.extensions.load()
|
||||
meta.publications.load()
|
||||
|
||||
backups.load()
|
||||
if (IS_PLATFORM) {
|
||||
backups.load()
|
||||
}
|
||||
vault.load()
|
||||
}
|
||||
}, [ui.selectedProject?.ref])
|
||||
|
||||
@@ -7,6 +7,9 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
||||
// this is required to use shared packages in the packages directory
|
||||
const withTM = require('next-transpile-modules')(['ui', 'common'])
|
||||
|
||||
// Required for nextjs standalone build
|
||||
const path = require('path')
|
||||
|
||||
// This file sets a custom webpack configuration to use your Next.js app
|
||||
// with Sentry.
|
||||
// https://nextjs.org/docs/api-reference/next.config.js/introduction
|
||||
@@ -166,6 +169,11 @@ const nextConfig = {
|
||||
images: {
|
||||
domains: ['github.com'],
|
||||
},
|
||||
// Ref: https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
|
||||
experimental: {
|
||||
outputStandalone: true,
|
||||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||||
},
|
||||
}
|
||||
|
||||
// Export all config
|
||||
|
||||
Reference in new issue
Block a user