Skip to content

Instantly share code, notes, and snippets.

Created June 5, 2012 21:47
Show Gist options
  • Save luckyruby/2878267 to your computer and use it in GitHub Desktop.
Save luckyruby/2878267 to your computer and use it in GitHub Desktop.
16:19 t432: What is the best way to approach the following problem.... A user logs in, application connects to database, retrieves latest 100 records and display the content. if user scrolls to bottom of page, retrieve next 100 records and display continue till end. In addition if a new record is created whilst logged in automatically display record on top... Might look familiar you use twitter
16:19 mattgordon has joined (~mattgordo@
16:20 will_: Great :)
16:20 Psi-Jack: I'm also using the primary_conninfo line in recovery.conf.
16:20 Psi-Jack: And trigger_File.
16:20 Psi-Jack: But, it's simply not streaming. :)
16:20 Psi-Jack: I'
16:20 luckyruby: t432, what web framework are u using?
16:21 orf_ has left IRC (Quit: Leaving)
16:21 bwlang_ has joined (
16:21 luckyruby: there's usually pagination libraries that help with that
16:21 t432: I'm not using a framework - traditional jsp/servlet
16:21 t432: I am open to using framework if it will help
16:21 Psi-Jack: What I'm doing from the master server is my archive_command= 'ssh psql02 ! test -f walrecv/%f && rsync -az %p psql02:walrecv/%f'
16:21 luckyruby: t432, look into ruby on rails and the will_paginate gem
16:21 Psi-Jack: And walrecv is receiving.
16:22 t432: I've used rails before- this is a java project
16:22 luckyruby: look into play then
16:22 t432: I intent to develop a mobile app that why I'm going with java
16:22 t432: intend*
16:22 luckyruby: what does mobile app have to do with java?
16:23 kaare_ has joined (
16:23 t432: android is in java
16:23 Psi-Jack: Well, sorta java...
16:23 Psi-Jack: Dalvik java.
16:23 luckyruby: don't let oracle hear you say that :)
16:23 luckyruby: are you building a native or web app?
16:24 t432: yeah .. i know... I went with java because i'm hoping it will save me some time when it comes to developing the app
16:24 t432: copy and paste pojos
16:24 mbalmer: mobile == java ? you kiddin, right?
16:24 plq has left IRC (Remote host closed the connection)
16:24 t432: mbalmer: its reality
16:24 janos_: technically it started there!
16:24 Psi-Jack: Wow, I'm at work LATE! Holy crap! Time to head home. LOL
16:24 bwlang has left IRC (Ping timeout: 248 seconds)
16:24 bwlang_ is now known as bwlang
16:25 mbalmer: t432, wake up from your bad dream.
16:25 jpa1 has left IRC (Quit: Leaving.)
16:26 t432: mbalmer: Android is not a figment of my imagination :)
16:26 t432: well atleast I hope not
16:26 fission6 has left IRC (Ping timeout: 244 seconds)
16:26 t432: lets face Android is actually a Java Platform
16:27 t432: face it*
16:27 ddyne has left IRC (Quit: gone for now. back soon.)
16:27 mbalmer: yes, probably.
16:27 bencc: how can I use the extended query syntax to insert multiple rows with a param?
16:28 bencc: I want to insert several rows to the contacts table of the same user when I have an array of his contact ids
16:30 luckyruby: t432, are you building a web or native app? If you're building a web app, I've never heard of java being used to save on dev time.
16:30 t432: native
16:30 agliodbs has left IRC (Quit: agliodbs)
16:31 luckyruby: so postgresql runs on android?
16:31 t432: I'm building a ordinary website to along with app
16:31 pertl has left IRC (Quit: pertl)
16:31 t432: well..native apps can connect to the server to retrive data right?
16:31 luckyruby: yeah, but they can communicate via rest interfaces where the web side can be anything
16:32 g0bl1n has joined (
16:32 g0bl1n has left IRC (Changing host)
16:32 g0bl1n has joined (~prokter@unaffiliated/g0bl1n)
16:32 luckyruby: if you're building web apis, you might want to take a look at sinatra.
16:32 t432: I dont think I will be needing an api for this
16:33 Guest11890 has joined (
16:33 t432: app can connect to server directly
16:33 t432: api is generally used to make things available to other developers
16:34 Berge: t432: There are lots of problems with connecting directly to postgres from an android app.
16:34 Berge: It won't scale very well, for one.
16:34 Berge: Authentication is another.
16:34 etcetera has joined (u2560@about/csharp/regular/etcetera)
16:34 mastermind has left IRC (Ping timeout: 272 seconds)
16:34 Berge: The postgres protocol over unstable high latency links won't be pleasant.
16:35 t432: well... app can connect to the server, the server will than retrieve data from db and send it across, app wont be connecting directly
16:35 Merwin_ has left IRC (Ping timeout: 248 seconds)
16:35 Berge: t432: ah
16:35 Berge: t432: And you're writing the server in java?
16:35 t432: yes
16:35 t432: I'm wrting a servlet that sites on the server
16:36 t432: listens for incoming requests
16:36 bwlang_ has joined (
16:36 Berge: Right. So the java part has nothing to do with the mobile development part.
16:36 t432: nope
16:36 mike84 has left IRC (Quit: Verlassend)
16:36 fisted has left IRC (Read error: Connection reset by peer)
16:36 Berge: But to answer your original question; you might want to check out LISTEN/NOTIFY.
16:36 t432: well... mobile app will also be in Java
16:36 sobel: not that it should have to matter
16:36 t432: becuase it will be an Android App
16:37 Berge: (And pagination is easily done with LIMIT and OFFSET.)
16:37 sobel: AFAIK java on android is not the most ideal option but it's a fairly well-worn path
16:37 t432: Berge... I'd prefer it to be an application solution than a database
16:37 Berge: t432: Then I don't understand your question, I think.
16:37 Merwin has joined (~quassel@
16:37 luckyruby: t432, you're honestly better off not reinventing the wheel here and using a framework + libraries that already do this.
16:38 Berge: +1
16:38 luckyruby: look into the play framework if you're hellbent on using java.
16:38 t432: luckyruby: I have no problem doing with that if it will make life easier
16:39 t432: not sure which to go with spring or play
16:39 bwlang has left IRC (Ping timeout: 265 seconds)
16:39 bwlang_ is now known as bwlang
16:39 t432: not faimilar with play
16:39 luckyruby: is spring for the web?
16:39 Bollinger has left IRC (Quit: Bye)
16:39 t432: yes
16:39 t432: it has mvc library
16:40 sobel: I think very highly of Spring/WebMVC
16:40 sobel: in fact, i'm hooked on declarative programming in java with Spring.
16:40 sobel: it is bomb-like.
16:40 t432: Spring it is then
16:40 Bastian82 has left IRC (Ping timeout: 252 seconds)
16:41 sobel: that said, i have no idea if it's just as awesome on the client. it does make excellent sense for server applications, though.
16:41 Berge: There are different opinions on the matter, of course (-:
16:41 sobel: certainly. i have only my own to offer.
16:41 Berge: I wouldn't touch it with fairly long poles.
16:42 Berge: But go with whatever you're used to and know if development speed is a factor.
16:42 sobel: is that because you hate java or spring?
16:42 Berge: Or, the most important factor, at least.
16:42 t432: Stripes was fairly neat framework, word is it is dying out
16:42 Berge: Er, well, both. (-:
16:42 t432: community denies it but cant afford to take the risk of using it
16:42 sobel: tell me a more performant language that is popular for the web that isn't C or C++
16:42 t432: c or C++ is not for the web
16:42 will_: PLPGSQL
16:43 Berge: Java as a language isn't all that bad, but the VM's are usually a nightmare to sysadmin, and most java libraries are either too verbose, overcomplex or both.
16:43 sobel: agreed
16:43 t432: Java is the best out there
16:43 t432: enterprise standard
16:43 sobel: i'm not sympathetic to those who think jvms are that hard to admin
16:43 Berge: It depends on what you're oding.
16:43 Berge: doing
16:43 feivel has joined (
16:43 sobel: C# knocked off java libraries because they are *good*
16:43 luckyruby: lol t432, if that isn't trollbait...
16:43 sobel: Boost knocked off java libraries because they are *good*
16:43 Berge: Number crunching or long-running loops aren't the main bottlenecks of web, usually.
16:43 t432: lucyruby: what do you mean?
16:43 janos_: c# has moved past being a knock-off
16:43 sobel: no
16:44 janos_: it moved past that years ago
16:44 sobel: janos_: yeah, i'm not current on anything Microsoft, but history is what it is
16:44 tkellen has joined (~tkellen@
16:44 janos_: sobel: yep
16:44 Berge: You can get pretty far with any of the modern, JITed or half-JITed scripting languages. (Apart from ruby, perhaps.)
16:44 Guest11890 is now known as davidw
16:44 MrGando has left IRC (Remote host closed the connection)
16:44 davidw has left IRC (Changing host)
16:44 davidw has joined (~davidw@apache/committer/davidw)
16:45 t432: luckyruby: rails is not actually a programmers tools....
16:45 pertl has joined (
16:45 sobel: Rails is a serious detriment to a data-oriented application
16:45 t432: I know Rails i've used it before
16:45 sobel: Rails is a crutch for people who don't have a DBA or think of the database as bit bucket
16:45 Berge: And the Rails ORM is awful.
16:45 Berge: sobel: Indeed.
16:45 himancha1i has joined (~himanchal@
16:46 feivel_ has left IRC (Ping timeout: 252 seconds)
16:46 sobel: i have a lot of experience making java apps that are clean, perform well, and can be maintained. that was like the entire 2000s for me.
16:46 t432: Rails is pretty neat if you want to get your app running real quick but its not something you would use to build serious application
16:46 himanchali has left IRC (Read error: Connection reset by peer)
16:46 sobel: i checked back lately to see what the state of tools was like, and things have gotten better still
16:46 luckyruby: t432, right cause ya know... no big companies use rails
16:46 sobel: hey, my big company uses rails
16:47 sobel: and that is my biggest argument against it. it is a failure.
16:47 sobel: and everyone knows it except those who are not data aware
16:47 t432: luckyrails: you mean twitter?
16:47 Berge: Lots of big companies use rail. But big companies don't always do the right thing. Usually not, in fact. (-:
16:47 t432: they been regretting ever since
16:47 t432: it*
16:47 Berge: Twitter has been rewrittenl.
16:47 sobel: they bought into rails, and now outsource their rails problems to my team. bury/forget style.
16:47 Berge: No part is still on rails.
16:48 janos_: it went off the rails?
16:48 Junior has left IRC (Quit: Juni......)
16:48 janos_: *drum roll*
16:48 alecm_: *tumbleweed*
16:48 janos_: ;(
16:48 Berge: *ka-ding-tisch*
16:48 alecm_: :P
16:48 sobel: getting your app running real quick is not a great plan if you hope to use it beyond several weeks worth of hacking
16:48 luckyruby: sobel, what company do you work for if you don't mind me asking?
16:49 sobel: luckyruby: we're called Enova. I believe we have a section in pgxn for some of the postgres (pl/pgsql) code we've contribute to the commons
16:49 luckyruby: sobel: that's not been my experience with rails.
16:49 sobel: it's 100% of the experiences i can find in profitable companies.
16:50 sobel: i would not create that problem knowingly myself. i just know what i've seen over and over, ever since i was in the position of destroying a competitor who thought mod_ruby was a good idea in 2003
16:50 t432: I think Rails is a great framework .... but it takes care of alot stuff for you which can be a drawback
16:50 luckyruby: I can honestly say the same about java in my company.
16:50 Bastian82 has joined (~none@
16:51 sobel: I have seen failures in java, but they were doing it wrong. The Rails failures I have seen were doing it "right" as far as Rails community was concerned.
16:51 luckyruby: java has been a complete failure for us but mainly that's cause we have shitty java developers. Perhaps the same can be said about yours?
16:51 bwlang_ has joined (
16:51 mbalmer has left IRC (Quit: Mais uma caneca!)
16:51 t432: Java is hard to break if build proerly
16:51 t432: properly*
16:51 sobel: yes, the front-end developers at my company several years ago (so a different crowd than now) failed to make java work better than rails given a 2 week trial. it was the dumbest way to compare languages, imo.
16:51 janos_: that's one heck of a caveat ;)
16:51 sgrover has joined (~quassel@
16:51 t432: it is the enterprise standard no other platform comes close
16:52 sobel: it's like picking your cross-country vehicle based on 0-60 performance
16:52 mastermind has joined (
16:52 Peste_Bubonica has left IRC (Remote host closed the connection)
16:52 sobel: i have been most surprised by the steady improvement and growth in java's quality. rails, comparatively, has gone next to nowhere in 10 years.
16:53 sobel: it remains a horrible choice for performance and functionality
16:53 luckyruby: except rails hasn't been around for 10 years?
16:53 t432: My college dissertation was on Rails
16:53 sobel: whatever they were using with mod_ruby in 2003 was poor. i guess they weren't using rails then.
16:53 t432: so I know a little about Rails
16:53 sgrover: Q: What is the simplest way to mirror an access database (tables and data only) to pgsql? The docs I see so far only seem to support pg7
16:53 kaare_ has left IRC (Ping timeout: 252 seconds)
16:53 luckyruby: ok well i gotta go back to doing real work
16:54 t432: yeah me too... Spring it is
16:54 t432: thanks
16:54 sobel: hehe
16:54 sobel: <3 spring
16:54 bwlang has left IRC (Ping timeout: 250 seconds)
16:54 bwlang_ is now known as bwlang
16:54 luckyruby: i get that rails isn't your cup of tea but the amount of misinformation being spread is offputting
16:54 t432: luckyruby: I use Rails
16:55 t432: just not on this project :)
16:55 sobel: you are factually incorrect to call it misinformation
16:55 pdtpatrick has left IRC (Quit: pdtpatrick)
16:56 t432: Now Ruby is a great scripting language
16:56 luckyruby: well, first of all we're comparing java with rails, which isn't apples to apples.
16:56 t432: Did you know you can build apps in Rails without even fully know Ruby?
16:56 luckyruby: if you compared say, struts..
16:56 t432: knowing*
16:56 luckyruby: t432, you're in for a world of pain if you don't have a solid ruby foundation
16:56 t432: luckyruby: agreed
16:57 spicyWith has left IRC (Quit: spicyWith)
16:57 janos_: t432: not surprising. most of teh net is made without people fully knowing much of anything
16:57 Robe: 8
16:57 t432: agree with your 3rd last post
16:57 t432: rails has it unique take on ruby
16:57 sobel: i can't find it now, but arstechnica benched all the popular dynamic languages
16:57 t432: its*
16:58 sobel: using C/C++ as the standard (1.0) they ranked other languages as multiples of C/C++ performance
16:58 sobel: java was a 2
16:58 sobel: twice as slow as C. and it was the winner, head and shoulders above the rest
16:58 sobel: i think Erlang placed somewhat favorably
16:59 Berge: It's partly about what tricks you can use as well. I tend to like mod_perl, which allows you to to all kinds of trickery performance-wise.
16:59 sobel: python/perl were near the middle, at something like 25-35x slower than C
16:59 sobel: Ruby: a full 72x slower than C
16:59 sobel: trickery like saving VM startup overheads?
16:59 Berge: You can start sending HTML to the client while querying the DB, for instance, which is a great performance-win even though perl executes slower than ie. java.
16:59 pdtpatrick has joined (
17:00 JohanW_Home has left ()
17:00 sobel: unless your payload size is crazy, that's not a big win
17:00 t432: sobel: Java is for Web and C is more Machines
17:00 g0bl1n has left IRC (Read error: Connection reset by peer)
17:00 sobel: C is just the performance benchmark, they weren't suggesting C should be used for web-facing programming
17:00 g0bl1n has joined (
17:00 t432: that are both in different classes
17:01 will_ has left IRC (Disconnected by services)
17:01 sobel: yes, that's not lost on me at all
17:01 t432: not that you can't build java software for devices
17:01 dragansah has joined (~dragan@
17:01 will_ has joined (~Adium@pdpc/supporter/professional/will)
17:01 sobel: "lies, damn lies, pillow talk, then benchmarks, in order of increasing ridiculosity"
17:01 TitanOfOld has left IRC (Read error: Operation timed out)
17:01 Berge: sobel: It's a nice latency win, actually.
17:02 Berge: (And a nice perceived win if you can output enough HTML so that the web browser can start rendering while you're doing heavy lifting.)
17:02 t432: In fact Java is suppose to be ideal for embedded systems but I think C has the edge over Java for this
17:02 fisted has joined (~fisted@unaffiliated/fisted)
17:03 yates: is there a crosstab query in SQL?
17:03 t432: Why on earth did Steve Jobs go with Object-C is beyond me
17:03 bhunt has joined (
17:03 sobel: no, Oak, the language Java descended from >10 years ago, was designed for embedded systems
17:03 t432: what was wrong c?
17:03 sobel: Java SE has become something entirely different
17:04 sobel: meeting time. good chat, more later...
17:04 bhunt has left ()
17:04 t432: Larry Elisson got his as kicked in court when tried to sue Google for Android
17:04 sobel: oh save it for when i can weigh in on that :)
17:04 t432: ass*
17:05 claes_ has left IRC (Quit: claes_)
17:05 RaceCondition has joined (
17:05 t432: Google's lawyers had him huffing and puffing in cross-examination
17:06 bwlang_ has joined (
17:06 t432: thats all you need to know
17:06 NIN101 has left IRC (Quit: NIN101)
17:06 seekwill has joined (~wfong@pdpc/supporter/professional/will)
17:06 fission6 has joined (
17:07 dantti_laptop has left IRC (Quit: KVIrc 4.1.3 Equilibrium
17:08 mschiff has joined (~mschiff@gentoo/developer/mschiff)
17:09 alester has joined (
17:09 bwlang has left IRC (Ping timeout: 252 seconds)
17:09 bwlang_ is now known as bwlang
17:09 Tobu has left IRC (Ping timeout: 248 seconds)
17:11 TitanOfOld has joined (~titan@gentoo/developer/TitanOfOld)
17:12 t432: luckyruby: Say hi to your friend -!/dhh
17:12 luckyruby: ?
17:13 hynek has left IRC (Quit: Leaving...)
17:13 t432: open the link
17:13 t432: if you want to get the joke
17:13 hynek has joined (~hynek@pdpc/supporter/active/hynek)
17:13 t432: else ignore
17:13 hynek has left IRC (Read error: Connection reset by peer)
17:14 converge has left IRC (Quit: Linkinus -
17:14 luckyruby: I clicked the link. I don't follow the joke.
17:14 githogori has joined (
17:15 t432: luckyruby: He the person that created Ruby On Rails
17:15 t432: He is*
17:15 luckyruby: did you learn that in your dissertation?
17:16 t432: In fact, yes
17:16 t432: :)
17:16 t432: way back
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment