query | use index | planning time | exec time |
---|---|---|---|
where name ilike '%Shandeigh%'; |
false | <=0.1ms | ~300ms |
where name ilike '%Shandeigh%'; |
true | ~0.1ms | 0.05ms < x < 0.1ms |
where name ilike '%Shandeigh%' and created_at > '2022-07-01 08:41:14.515 +0700'; |
true | ~0.1ms | 0.05ms < x < 0.1ms |
where ts @@ to_tsquery('Shandeigh'); |
false | <= 0.09ms | ~700ms |
where ts @@ to_tsquery('Shandeigh'); |
true | ~0.1ms | ~0.05ms |
where ts @@ to_tsquery('Shandeigh') and created_at > '2022-07-01 08:41:14.515 +0700'; |
true | ~0.1ms | ~0.05ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE INDEX trgm_idx_fts ON name USING GIN (ts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into MOCK_DATA (name, created_at) values (?, ?); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table MOCK_DATA ( | |
id SERIAL, | |
name VARCHAR(100), | |
created_at timestampz, | |
ts tsvector generated always as (to_tsvector('english'::regconfig, name)) stored | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector @@ 'cat & rat'::tsquery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT name FROM mentors WHERE name LIKE '%ridho%'; |
id | name |
---|---|
1 | anakin skywalker |
2 | ridho rhoma |
3 | gabriel martinelli |
4 | elkan baggot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func printEngineerName(names []string) { | |
for index, engineer := range names { | |
fmt.Printf("Some string at index %v with value %v", index, engineer) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func addEngineerAndPrintNames(currentEngineer []string, newEngineer string) (updatedEngineers []string) { | |
updatedEngineers = append(currentEngineer, newEngineer) | |
for index, engineer := range updatedEngineers { | |
fmt.Printf("Some string at index %v with value %v", index, engineer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
// Print engineer names that is still junior | |
func printEngineerName(names []string, isJunior bool) { | |
if !isJunior { | |
return |
NewerOlder