-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anyone have a plain PG example, i.e. not using ActiveRecord or other ORM? #84
Comments
If you have the process version working post some code, I saw weird issues in the tests we did so far #83 |
On Tue, 2013-10-15 at 21:40 -0700, Michael Grosser wrote:
dbname='test' ####################################################################### $ pg_dump -s -t test test---- PostgreSQL database dump--SET statement_timeout = 0;SET client_encoding = 'UTF8';SET standard_conforming_strings = on;SET check_function_bodies = false;SET client_min_messages = warning;SET search_path = public, pg_catalog;SET default_tablespace = '';SET default_with_oids = false;---- Name: test; Type: TABLE; Schema: public; Owner: rthompso; Tablespace:--CREATE TABLE test (a integer,str text,myserial integer NOT NULL);ALTER TABLE public.test OWNER TO rthompso;---- Name: test_myserial_seq; Type: SEQUENCE; Schema: public; Owner: rthompso--CREATE SEQUENCE test_myserial_seqSTART WITH 1INCREMENT BY 1NO MINVALUENO MAXVALUECACHE 1;ALTER TABLE public.test_myserial_seq OWNER TO rthompso;---- Name: test_myserial_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: rthompso--ALTER SEQUENCE test_myserial_seq OWNED BY test.myserial;---- Name: myserial; Type: DEFAULT; Schema: public; Owner: rthompso--ALTER TABLE ONLY test ALTER COLUMN myserial SET DEFAULT nextval('test_myserial_seq'::regclass);---- PostgreSQL database dump complete--####################################################################### ####################################################################### $ cat /tmp/testdata1 '6652491'2 '6578035'3 '6607464'4 '6610893'5 '6620404'... snip ...1700 '7003391'####################################################################### File.foreach("/tmp/testdata").each_slice(60) do |line_array|
you could prob leave off this close, as the process exit will close the connection
end |
you should be able to do @connection ||= PGconn.connect as every fork only On Wed, Oct 16, 2013 at 11:42 AM, jreidthompson notifications@github.comwrote:
|
On Tue, 2013-10-15 at 21:40 -0700, Michael Grosser wrote:
$ ruby -v require 'rubygems' dbname='test' File.foreach("/tmp/testdata").each_slice(100) do |line_array|
end |
On Wed, 2013-10-16 at 11:47 -0700, Michael Grosser wrote:
slightly confused
I, [2013-10-16 15:51:16#6118] INFO -- : process line: 2 '6578035' I, [2013-10-16 15:51:16#6119] INFO -- : process line: 3 '6607464' I, [2013-10-16 15:51:16#6120] INFO -- : process line: 4 '6610893' I, [2013-10-16 15:51:16#6121] INFO -- : process line: 5 '6620404' I, [2013-10-16 15:51:16#6122] INFO -- : process line: 6 '6626819' I, [2013-10-16 15:51:16#6123] INFO -- : process line: 7 '6584929' I, [2013-10-16 15:51:16#6124] INFO -- : process line: 8 '6320761' I, [2013-10-16 15:51:16#6125] INFO -- : process line: 9 '6320985' I, [2013-10-16 15:51:16#6126] INFO -- : process line: 10 '7001250' I, [2013-10-16 15:51:16#6127] INFO -- : process line: 11 '6587709' I, [2013-10-16 15:51:16#6128] INFO -- : process line: 12 '6611125' I, [2013-10-16 15:51:16#6129] INFO -- : process line: 13 '6630632' I, [2013-10-16 15:51:16#6131] INFO -- : process line: 15 '6657703' I, [2013-10-16 15:51:16#6118] INFO -- : end processing 6118 I, [2013-10-16 15:51:16#6122] INFO -- : end processing 6122
|
1: yes On Wed, Oct 16, 2013 at 12:51 PM, jreidthompson notifications@github.comwrote:
|
On 10/16/2013 3:56 PM, Michael Grosser wrote:
ok I see File.foreach("/tmp/testdata").each_slice(1000) do |line_array| generates a total of 30 forked processes. so, modifying the previous test a little bit, then validation = add pid column to table alter the script to manage the dbconnection and prepared statement per File.foreach("/tmp/testdata").each_slice(1000) do |line_array|
dbuser, :password => dbpwd, :host => pghost, :port => pgport)
"INSERT into test(a, str, pid) values($1::integer, $2::text, $3::integer);")
[count, value, $$]) puts "end processing #{$$.to_s}"have to leave this out, or it bails out after the first 15 insertsyou could prob leave off this close, as the process exit will closethe connection res = @DB1Connection.closeif ( res.result_status > 4 )@log.error "DB insert error: " + res.result_status.to_sendres.clear
end .... [19:21:07][0s] rthompso@raker2.ateb.com> /tmp count2000 [19:21:48][0s] rthompso@raker2.ateb.com> /tmp |
prob should mention version |
didn't realize I was that far behind -- updated to latest |
But it still fails right ? Not sure what to do :/ |
same code as in process test except for: real 0m38.840s ------some quick simple tests --- 15 processes/2000 line file/1 2000 line chunk [19:59:46][7s] rthompso@raker2.ateb.com> /tmp real 0m8.039s real 0m14.124s real 0m4.941s real 0m4.934s [20:00:51][5s] rthompso@raker2.ateb.com> /tmp 15 ?threads? (GIL) /2000 line file/1 2000 line chunk [20:01:06][6s] rthompso@raker2.ateb.com> /tmp real 1m9.523s real 1m21.338s real 1m7.278s |
no -- not failing -- these appear to be working for me |
I can't seem to find a way to make it work for threads. I think I have a process version working.
The text was updated successfully, but these errors were encountered: