how to avoid pg to parse a result object
See original GitHub issueI’m using api-service as a proxy between PostgreSQL and client
so JSON.parse
result from PostgreSQL and JSON.stringify
the result to client is unnecessary and only eat service time.
Could I switch off parsing response from PostgreSQL into JSON?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Parsing a PostgreSQL result object in a Rails app
Is there any built-in PG way to do this, or a workaround, or anything really? Here is the query I'm using: SELECT row_to_json(row(company_name, ......
Read more >Understanding PG Result object - Kiprosh Blogs
Understanding PG Result object. In rails one of the way to execute raw query is use of ActiveRecord::Base.connection.execute.
Read more >Work Easily With JSON Using PostgreSQL Parse JSON - Learn
You can parse the JSON objects using PostgreSQL's JSON operators and functions, and then insert the values into your desired PostgreSQL tables ...
Read more >Queries – node-postgres
This will inform the result parser to bypass collecting rows into a JavaScript object, and instead will return each row as an array...
Read more >9.15. JSON Functions and Operators - PostgreSQL
Function Return Type Example Example Result
array_to_json(anyarray ) json array_to_json(''::int)
row_to_json(record ) json row_to_json(row(1,'foo'))
to_json(anyelement) json to_json('Fred said "Hi."'::text) "Fred said \"Hi.\""
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s about 5000 rows with about 1kb of JSON each. I didn’t run the test with pg, I just ran
explain analyze
on the queries with and without::text
, and somehow the text conversion did slow it down a lot. (I wonder if it’s just because Postgres doesn’t normally count the serialization of the row data as part of the execution time?)I eventually found a way to prevent parsing using the types property:
thanks !