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
#psql | |
postgres=# \l | |
List of databases | |
Name | Owner | Encoding | Collate | Ctype | Access privileges | |
-------------+---------+----------+-------------+-------------+--------------------- | |
my_database | sdc | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/sdc + | |
| | | | | sdc=CTc/sdc | |
postgres | Stephen | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | |
sdc | Stephen | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/Stephen + | |
| | | | | Stephen=CTc/Stephen+ |
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
```psql | |
sdc=# \dp descriptions | |
Access privileges | |
Schema | Name | Type | Access privileges | Column privileges | Policies | |
--------+--------------+-------+-------------------------+-------------------+---------- | |
public | descriptions | table | Stephen=arwdDxt/Stephen+| | | |
| | | sdc=arwdDxt/Stephen | | | |
``` |
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
```js | |
//insertToPostgres.js | |
const { client } = require('pg'); | |
const config = require('../config.json'); | |
... | |
const table = 'descriptions'; | |
const fields = 'product_id, product_name, features, tech_specs' | |
const host = config.host; |
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 (product_id, product_name, created_at) FROM descriptions WHERE product_id = 19282; | |
SELECT COUNT(product_id) FROM descriptions; | |
SELECT (product_id, product_name, created_at) FROM descriptions ORDER BY created_at DESC LIMIT 10; |
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
db.descriptions.find( { productId: 1928222 } ) | |
db.descriptions.find( { productId: { $gt : 9999990 } } ) |
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
//mongo sh | |
> db.descriptions.createIndex( { productId: 1 } ) | |
{ | |
"createdCollectionAutomatically" : false, | |
"numIndexesBefore" : 1, | |
"numIndexesAfter" : 2, | |
"ok" : 1 | |
} |
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
// mongo sh | |
> db.descriptions.getIndexes() | |
[ | |
{ | |
"v" : 2, | |
"key" : { | |
"_id" : 1 | |
}, | |
"name" : "_id_", | |
"ns" : "trailblazer.descriptions" |
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
// mongo sh | |
> db.descriptions.dropIndex("product_id_1") | |
{ "nIndexesWas" : 2, "ok" : 1 } | |
> db.descriptions.dropIndexes() | |
{ | |
"nIndexesWas" : 2, | |
"msg" : "non-_id indexes dropped for collection", | |
"ok" : 1 | |
} |
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
//mongo sh | |
db.descriptions.find( {productId: {$gt : 9999990 } } ).explain("executionStats") | |
{ | |
"queryPlanner" : { | |
"plannerVersion" : 1, | |
"namespace" : "trailblazer.descriptions", | |
"indexFilterSet" : false, | |
"parsedQuery" : { | |
"productId" : { | |
"$gt" : 9999990 |
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
//mongo sh | |
db.descriptions.find( {productId: {$gt : 9999990 } } ).explain("executionStats") | |
{ | |
"queryPlanner" : { | |
"plannerVersion" : 1, | |
"namespace" : "trailblazer.descriptions", | |
"indexFilterSet" : false, | |
"parsedQuery" : { | |
"productId" : { | |
"$gt" : 9999990 |