Fork me on GitHub
#sql
<
2018-08-13
>
jaihindhreddy-duplicate08:08:29

This might belong in #beginners but... What's the idiomatic way to copy over a table (for backup) from one database to another with constant memory usage (table fits neither in memory nor on disk)?

valtteri13:08:02

But.. if you don’t need to do it programmatically, I’d do just something like pg_dump my_first_db -t my_table | psql my_other_db

valtteri13:08:10

Assuming postgres

rcustodio16:08:02

hey y’all…

rcustodio16:08:01

I got a beginner question, honestly, the jdbc (mysql), how does it work when you use query? open con > open stt > read > close stt > close con??? Or it always maintain 1 connection open?

rcustodio16:08:35

I’m really having problems with c3p0 or hikari because there’r TOO MUCH DBs to connect, pooling is not working since I cannot do 1 pool for all dbs

hiredman16:08:39

I've never seen a real app not use a connection pool like c3p0 or hikari

hiredman16:08:22

I am not sure what you mean by too much dbs

rcustodio17:08:32

@hiredman its an ecommerce, so there’s more than 500 stores, and they are separated dbs

rcustodio17:08:16

I know what you mean… c3p0 or hikari its really helpful, so mysql does not go crazy

jgh17:08:44

i wonder if you need to rethink your architecture a little bit here

rcustodio17:08:53

YEah @jgh we are thinking about remove the MySQL, but till there… trying to use clojure to do some stuffs

jgh17:08:30

i mean im not sure mysql is your problem. Is having one application connect to all of your servers directly really the best way to do it?

☝️ 4
rcustodio17:08:27

all servers you mean all dbs?

rcustodio17:08:10

like.. limit the project, connect from x to y, another connect from a to h

rcustodio17:08:13

something like it?

jgh17:08:14

I have no idea what you're trying to do so it's hard for me to make suggestions, but I suspect that there's a better way to do whatever it is you're trying to do than have a single clojure app connect to hundreds of databases.

hiredman17:08:57

database is sort of an overloaded term, it can mean sort of a namespace within a database server, or it can mean a database server itself, from "500 stores" my guess is your project started as a single store, and to make it multi-tenant database (in the namespace of tables sense) was added for each tenant instead of making the schema multi tenant in a single database

rcustodio17:08:29

@hiredman its a in-company project, it was like that when I got hired, not much to do, and yeah.. schemas, multi-schemas

hiredman17:08:55

I think if I was in that situation, I might start by creating a pool of connection pools

hiredman17:08:53

because, I dunno, it seems like it should be a valid thing to do, but I think in general it is done the otherway, so most off the shelf solutions are going to fight you

rcustodio17:08:11

I see… pool of connection pool… so would limit the connection pool itself, right?

hiredman17:08:22

why do you need to limit it?

rcustodio17:08:41

not limit it.. but not let it goes crazy and outofmemory

rcustodio17:08:55

atm in having deadlock problem on c3p0

hiredman17:08:02

are you sure that is related to connection pooling?

rcustodio17:08:16

APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!

rcustodio17:08:43

Well.. I dunno java/c3p0 that well yet

rcustodio17:08:08

I dont have this problem in dev, just in production

hiredman17:08:41

my guess would be you don't have enough connections (either allowed by the database, or made available by your connection pool)

rcustodio17:08:33

here is the function to connet

rcustodio17:08:25

Maybe its ALLL WRONG

rcustodio17:08:31

such a noob at this, LOL

rcustodio17:08:54

And the database (mysq) architeture does not help much

rcustodio17:08:43

Its 1 mysql, with a lot of schemas, to try explain it better

seancorfield17:08:48

And you have a different user/password for every one of the 500 DBs?

rcustodio17:08:19

@seancorfield nope, just 1 user/pass

seancorfield17:08:47

OK, and that user has permissions to read/write every DB schema?

seancorfield17:08:16

If that's the case, I would use a single connection pool and use it everywhere for all of the DBs.

seancorfield17:08:29

In other words, don't create a separate pool for each DB.

rcustodio17:08:54

and how change db? or use another db, by query? select dbXX.tableXX?

seancorfield17:08:19

Yes, use the schema name in your queries.

rcustodio17:08:32

I see… gonna try that out @seancorfield

rcustodio17:08:42

Maybe with that I can even increase the pool siz

seancorfield17:08:53

That's much more scalable (given the constraints you're already running under).

seancorfield17:08:10

And, yes, you can have a decent sized pool, since you'll only have one of them for the entire app.