Skip to content

Instantly share code, notes, and snippets.

{
"settings": {
"number_of_shards": 2
},
"mappings": {
"properties" : {
"_class" : {
"type" : "text",
"fields" : {
"keyword" : {
server:
port: 9081
spring:
cloud:
schema-registry-client:
endpoint: http://${SCHEMA_REGISTRY_HOST:localhost}:${SCHEMA_REGISTRY_PORT:8081}
stream:
kafka:
binder:
server:
port: 9080
spring:
schema:
avro:
schema-locations:
- classpath:avro/*.avsc
cloud:
schema-registry-client:
{
"namespace": "com.spring.kafka.avro.user",
"type": "record",
"name": "UserEvent",
"fields": [
{
"name": "eventId",
"type": "string"
},
{
package com.postgres.jsonb.user.validation;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
{
"$schema": "https://json-schema.org/draft/2019-09/schema#",
"$id": "http://my-paintings-api.com/schemas/painting-schema.json",
"type": "object",
"required" : [
"profession", "gender", "maritalStatus", "dateOfBirth", "fatherName"
],
"properties" : {
"profession" : {
"type" : "string",
explain analyze select * from user_details where details @> '{"info" : {"crop" : "Corn", "farmSize": "2-3"}}' limit 50;
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..3501.85 rows=50 width=426) (actual time=0.016..0.587 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..262639.00 rows=3750 width=426) (actual time=0.015..0.581 rows=50 loops=1)|
Filter: (details @> '{"info": {"crop": "Corn", "farmSize": "2-3"}}'::jsonb) |
Rows Removed by Filter: 1046 |
Planning Time: 0.058 ms |
Execution Time: 0.613 ms
explain analyze select * from user_details where details -> 'info' ->> 'crop' = 'Corn' and details -> 'info' ->> 'farmSize' = '2-3' limit 50;
QUERY PLAN |
----------------------------------------------------------------------------------------------------------------------------------------------------------|
Limit (cost=1000.00..136551.01 rows=50 width=426) (actual time=3.764..4.346 rows=50 loops=1) |
-> Gather (cost=1000.00..255835.90 rows=94 width=426) (actual time=0.165..40.441 rows=50 loops=1) |
Workers Planned: 2 |
Workers Launched: 2
explain analyze select * from user_details where details -> 'info' ->> 'crop' = 'Corn' limit 50;
QUERY PLAN |
----------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..750.37 rows=50 width=426) (actual time=0.015..0.318 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..281389.00 rows=18750 width=426) (actual time=0.014..0.315 rows=50 loops=1)|
Filter: (((details -> 'info'::text) ->> 'crop'::text) = 'Corn'::text) |
Rows Removed by Filter: 210 |
Planning Time: 0.052 ms |
Execution Time: 0.335 ms
explain analyze select * from user_details where to_date(details ->>'dateOfBirth', 'YYYY-MM-DD') between '2000-03-01' and '2000-03-31' limit 50;
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..825.37 rows=50 width=426) (actual time=0.113..27.525 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..309514.00 rows=18750 width=426) (actual time=0.112..27.515 rows=50 loops=1) |
Filter: ((to_date((details ->> 'dateOfBirth'::text), 'YYYY-MM-DD'::text) >= '2000-0