Comments (3)
I'm not sure you can update a cursor via the protocol. You have more control over a cursor if you use text commands to manipulate it. What were you thinking of trying to do to the cursor?
from node-pg-cursor.
Hi,
I was thinking of selecting rows in a huge table (list of all animal
movements), iterate on them, and when some conditions are met for this
animal update columns given business criteria. Do a one pass processing.
I know how to achieve this in two phases processing (select then update),
but ... there is kind of stupid argument on adoption of nodejs for
accessing a huge database in our enterprise.
One of the last arguments to forbid Nodejs on these database is the lack of
select for update functionnality.
Personnaly I think a way to achieve that in node will be good, but I am
pretty sure that the real question on nodejs adoption must not be answered
on this sort of stupid arguments. I know for sure that we can live without
this functionnality.
Thank you for your time,
2015-03-10 16:56 GMT+01:00 Brian C [email protected]:
I'm not sure you can update a cursor via the protocol. You have more
control over a cursor if you use text commands to manipulate it. What were
you thinking of trying to do to the cursor?—
Reply to this email directly or view it on GitHub
#11 (comment)
.
from node-pg-cursor.
There are 2 approaching features to what you are discussing.
UPDATE table SET ... WHERE CURRENT OF cursor;
is a construct of postgres stored procecures pl/sql. It allows for updating rows as their are selected via the cursor.
SELECT ... FOR UPDATE
sql syntax. This enable to LOCK the selected rows so that a further UPDATE acts atomically on the rows.
cf for instance http://stackoverflow.com/questions/14710214/select-for-update-statement-in-postgresql
The feature you are requesting looks like the feature regarding pl/psql cursors. It is a sort of "update in place" where the rows can be updated as they are selected, hinting that this is faster than a select followed by an update.
I myself am looking for an efficient way of doing a sort of :
var cursor = ...; cursor.pipe(rowTransformer).pipe(cursor);
as a way to use javascript to do small transformations or cleanups on all rows of a table.
One option could be to install pl-v8 inside postgres and use the stored procedures cursors, but pl-v8 inside postgres has its own set of problems.
another option could be maybe to use node-pg-copy
to have a way to
1/ read a table
2/ transform the rows on the fly
3/ flush the rows into another table
This would give you a fast one pass processing at the price of duplicating the table.
(+ I am not sure node-pg-copy
is already ready for this)
Other than that, if your business criteria is simple and you don't really need javascript, use a pl/sql stored procedure.
from node-pg-cursor.
Related Issues (20)
- Access to result fields HOT 2
- Result of client.query(Cursor) is not an EventEmitter HOT 2
- Uncaught exception calling cursor.close() on exhausted cursor using pool connection HOT 1
- Event handler leak on noData queries
- Invalid JavaScript in the example
- Reading a cursor from name HOT 2
- Getting Next Results Programmatically HOT 5
- Consider adding a Promise for the 'done' state HOT 1
- JavaScript heap out of memory HOT 1
- typescript support? HOT 2
- pg-cursor cannot be bundled with webpack HOT 2
- Can not use connection for other queries while cursor is open. HOT 2
- cursor detail HOT 1
- Redshift: anyone knows? HOT 4
- documentation missed
- Does pg-cursor initiate a server-side cursor, or is only for "streaming"?
- Should Cursor#handleError remove noData and rowDescription listener?
- Make Cursors instances of stream.Readable HOT 1
- Invalid protocol sequence 'P' while in PortalSuspended state (Redshift)
- Portal labelling change breaks knex migrations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-pg-cursor.