Skip to content

Instantly share code, notes, and snippets.

View toficzak's full-sized avatar
🐱

Toficzak toficzak

🐱
View GitHub Profile
package krzysztof.javaee8.api.demo;
public class DemoDto {
public String message = "Message";
}
krzysztof $ mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 12.0.2, vendor: AdoptOpenJDK, runtime: /home/krzysztof/Programs/Java/jdk-12.0.2+10
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-25-generic", arch: "amd64", family: "unix"
opttest=> explain analyze select * from customer where first_name = 'Christopher';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on customer (cost=4.56..71.23 rows=19 width=22) (actual time=0.127..0.256 rows=60 loops=1)
Recheck Cond: ((first_name)::text = 'Christopher'::text)
Heap Blocks: exact=58
-> Bitmap Index Scan on first_name_idx (cost=0.00..4.56 rows=19 width=0) (actual time=0.100..0.101 rows=60 loops=1)
Index Cond: ((first_name)::text = 'Christopher'::text)
Planning Time: 0.394 ms
Execution Time: 0.305 ms
opttest=> explain analyze select * from customer where first_name = 'Christopher';
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Seq Scan on customer (cost=0.00..1924.00 rows=19 width=22) (actual time=0.037..18.706 rows=60 loops=1)
Filter: ((first_name)::text = 'Christopher'::text)
Rows Removed by Filter: 99940
Planning Time: 0.122 ms
Execution Time: 18.761 ms
(5 rows)
opttest=> \d customer
Table "public.customer"
Column | Type | Collation | Nullable | Default
------------+------------------------+-----------+----------+---------
id | bigint | | not null |
first_name | character varying(255) | | |
last_name | character varying(255) | | |
Indexes:
"customer_pkey" PRIMARY KEY, btree (id)
"test_index" btree (first_name varchar_pattern_ops)
opttest=> drop index test_index;
DROP INDEX
opttest=> create index test_index on customer (first_name);
CREATE INDEX
opttest=> explain analyze select * from customer where first_name = 'Christopher';
QUERY PLAN
-------------------------------------------------------------------------------------------------------
Seq Scan on customer (cost=0.00..193.00 rows=10 width=22) (actual time=0.034..2.317 rows=10 loops=1)
Filter: ((first_name)::text = 'Christopher'::text)
Rows Removed by Filter: 9990
Planning Time: 0.139 ms
Execution Time: 2.350 ms
(5 rows)
opttest=> \d customer
Table "public.customer"
Column | Type | Collation | Nullable | Default
------------+------------------------+-----------+----------+---------
id | bigint | | not null |
first_name | character varying(255) | | |
last_name | character varying(255) | | |
Indexes:
"customer_pkey" PRIMARY KEY, btree (id)
public void sendGreeting(Location location)
{
Optional.ofNullable(location)
.map(location::getName)
.orElse(this.willReturnSomeLocation());
}