Skip to content

Instantly share code, notes, and snippets.

explain analyze select * from user_details where details ->> 'hasDisability' = 'false' limit 50;
QUERY PLAN |
----------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..725.37 rows=50 width=426) (actual time=0.014..0.064 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..272014.00 rows=18750 width=426) (actual time=0.013..0.058 rows=50 loops=1)|
Filter: ((details ->> 'hasDisability'::text) = 'false'::text) |
Rows Removed by Filter: 70 |
Planning Time: 0.062 ms |
Execution Time: 0.079 ms
explain analyze select * from user_details where details ->> 'familyMembers' >= '1' and details ->> 'familyMembers' <= '3' limit 50;
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..775.37 rows=50 width=426) (actual time=0.019..0.656 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..290764.00 rows=18750 width=426) (actual time=0.018..0.652 rows=50 loops=1) |
Filter: (((details ->> 'familyMembers'::text) >= '1'::text) AND ((details ->> 'familyMembers'::text) <= '3'::text))|
Rows Removed by Filter: 100 |
Planning Time: 0.096 ms |
Execution Time:
explain analyze select * from user_details where jsonb_extract_path_text(details,'familyMembers') :: int = 9 limit 50;
QUERY PLAN |
-----------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..725.37 rows=50 width=426) (actual time=0.033..26.974 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..272014.00 rows=18750 width=426) (actual time=0.032..26.968 rows=50 loops=1)|
Filter: ((details ->> 'familyMembers'::text) = '9'::text) |
Rows Removed by Filter: 73588 |
Planning Time: 0.212 ms |
Execution Time: 26.997 ms
select * from user_details where details ->> 'profession' like '%Farm%' limit 50;
QUERY PLAN |
----------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..453.36 rows=50 width=426) (actual time=0.024..0.169 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..272014.00 rows=30000 width=426) (actual time=0.023..0.165 rows=50 loops=1)|
Filter: ((details ->> 'profession'::text) ~~ '%Farm%'::text) |
Rows Removed by Filter: 216 |
Planning Time: 0.152 ms |
Execution Time: 0.211 ms
explain analyze select * from user_details where details ->> 'profession' = 'Farmer' limit 50;
QUERY PLAN |
----------------------------------------------------------------------------------------------------------------------|
Limit (cost=0.00..725.37 rows=50 width=426) (actual time=0.014..0.247 rows=50 loops=1) |
-> Seq Scan on user_details (cost=0.00..272014.00 rows=18750 width=426) (actual time=0.013..0.241 rows=50 loops=1)|
Filter: ((details ->> 'profession'::text) = 'Farmer'::text) |
Rows Removed by Filter: 276 |
Planning Time: 0.075 ms |
Execution Time: 0.267 ms
server:
port: 9001
spring:
cloud:
stream:
function:
definition: fizzBuzzProducer;fizzBuzzProcessor;fizzBuzzConsumer
package com.kafka.sample.kafka;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
import java.util.Random;
package com.eresh.outbox;
import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.connect.connector.ConnectRecord;
import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.connect.data.Struct;
import org.apache.kafka.connect.header.Headers;
import org.apache.kafka.connect.transforms.Transformation;
import java.util.Map;
version: "3.5"
services:
# Install postgres and setup the user service database
postgres:
build: users-service/postgres
restart: always
ports:
- '5432:5432'
environment:
{
"name": "elastic-sink",
"config": {
"connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector",
"tasks.max": "1",
"topics": "users",
"connection.url": "http://elastic:9200",
"transforms": "unwrap,key",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.drop.tombstones": "false",