Skip to content

Instantly share code, notes, and snippets.

CREATE EXTENSION IF NOT EXISTS vector;
CREATE OR REPLACE FUNCTION public.generate_random_normalized_vector(dim integer)
RETURNS vector
LANGUAGE SQL
AS $function$
SELECT public.l2_normalize(array_agg(random()::real)::vector)
FROM generate_series(1, $1);
$function$;
@jkatz
jkatz / pg_embedding_hnsw_config.yml
Created August 10, 2023 18:53
ANN Benchmark (https://github.com/erikbern/ann-benchmarks) modules for HNSW implementations of pgvector and pg_embedding
float:
any:
- base_args: ['@metric']
constructor: PGEmbedding
disabled: false
docker_tag: ann-benchmarks-pg_embedding_hnsw
module: ann_benchmarks.algorithms.pg_embedding_hnsw
name: pg_embedding_hnsw
run_groups:
M-12:
-- This is based on the code from
-- https://raw.githubusercontent.com/CrunchyData/postgres-realtime-demo/main/examples/demo/demo1.sql
-- which was originally released under the Apache 2.0 License
-- https://github.com/CrunchyData/postgres-realtime-demo/blob/main/LICENSE
CREATE SEQUENCE public.room_id_1_seq AS int INCREMENT BY 2 START WITH 1;
CREATE SEQUENCE public.room_id_2_seq AS int INCREMENT BY 2 START WITH 2;
CREATE TABLE public.room (
id int DEFAULT nextval('room_id_1_seq') PRIMARY KEY,
name text NOT NULL
-- This is based on the code from
-- https://raw.githubusercontent.com/CrunchyData/postgres-realtime-demo/main/examples/demo/demo1.sql
-- which was originally released under the Apache 2.0 License
-- https://github.com/CrunchyData/postgres-realtime-demo/blob/main/LICENSE
CREATE TABLE public.room (
id int GENERATED BY DEFAULT AS IDENTITY (INCREMENT 2 START WITH 1) PRIMARY KEY,
name text NOT NULL
);
-- This is based on the code from
-- https://raw.githubusercontent.com/CrunchyData/postgres-realtime-demo/main/examples/demo/demo1.sql
-- which was originally released under the Apache 2.0 License
-- https://github.com/CrunchyData/postgres-realtime-demo/blob/main/LICENSE
/**
* Schema
*/
CREATE TABLE public.room (
id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
-- This is based on the code from
-- https://raw.githubusercontent.com/CrunchyData/postgres-realtime-demo/main/examples/demo/demo1.sql
-- which was originally released under the Apache 2.0 License
-- https://github.com/CrunchyData/postgres-realtime-demo/blob/main/LICENSE
/**
* Schema
*/
CREATE TABLE public.room (
id int GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
CREATE TABLE data (id int PRIMARY KEY);
INSERT INTO data SELECT * FROM generate_series(1,5000000);
----
EXPLAIN ANALYZE
WITH r AS (
SELECT (random() * (SELECT count(*) FROM data))::int x
)
SELECT data.*
FROM r
pgo create cluster postgres -n pgo --database=keycloak --username=admin --password=admin
# wait for startup
cat <<-EOF > kc-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: keycloak
labels:
const PASSWORD_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ 'abcdefghijklmnopqrstuvwxyz'
+ '01234567890'
+ '!#$%&()*+,-./:;<=>?@[]^_`{|}~\/"\' ';
function generateRandomPassword(passwordLength=16) {
// if crypto not defined, bail
if (!window.crypto) {
throw new Error('The "crypto" library is not available');
}
#!/bin/bash
# SET THIS TO BE YOUR DESIRED USERNAME
export MY_USER_NAME_FOR_CERT=`whoami`
# This directory is optional, but will use it to keep the CA root key safe
mkdir keys certs
chmod og-rwx keys certs
# Set up a directory that will serve as the pgconf mount