Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11649 > unrolled thread

Java DB rotation

Started byJim Lee <jimlee2907@yahoo.com>
First post2012-01-30 18:08 -0800
Last post2012-02-08 02:08 +1100
Articles 5 on this page of 25 — 8 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:08 -0800
    Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:12 -0500
      Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:14 -0500
        Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:20 -0800
          Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:34 -0500
          Re: Java DB rotation Robert Klemme <shortcutter@googlemail.com> - 2012-01-31 08:36 +0100
      Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:17 -0800
        Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:20 -0500
          Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:23 -0800
            Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:31 -0500
    Re: Java DB rotation Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-31 02:21 +0000
      Re: Java DB rotation Jim Lee <jimlee2907@yahoo.com> - 2012-01-30 18:24 -0800
        Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:32 -0500
          Re: Java DB rotation Robert Klemme <shortcutter@googlemail.com> - 2012-01-31 08:38 +0100
            Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-01-31 12:57 -0600
              Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-01-31 13:03 -0600
                Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:32 -0500
                  Re: Java DB rotation Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-02-01 13:49 -0600
                    Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-02-01 19:23 -0500
              Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:31 -0500
            Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-31 20:30 -0500
    Re: Java DB rotation Arne Vajhøj <arne@vajhoej.dk> - 2012-01-30 21:35 -0500
      Re: Java DB rotation Lew <noone@lewscanon.com> - 2012-01-30 22:54 -0800
    Re: Java DB rotation George Neuner <gneuner2@comcast.net> - 2012-02-02 14:05 -0500
    Re: Java DB rotation Rajiv Gupta <rajiv@invalid.com> - 2012-02-08 02:08 +1100

Page 2 of 2 — ← Prev page 1 [2]


#11688

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-01-31 20:30 -0500
Message-ID<4f2895b1$0$283$14726298@news.sunsite.dk>
In reply to#11672
On 1/31/2012 2:38 AM, Robert Klemme wrote:
> On 31.01.2012 03:32, Arne Vajhøj wrote:
>> On 1/30/2012 9:24 PM, Jim Lee wrote:
>>> On Tue, 31 Jan 2012 02:21:11 +0000 (UTC), Martin Gregorie
>>> <martin@address-in-sig.invalid> wrote:
>>>> On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee wrote:
>>>>> I have a Java server controller that read/write to Database table
>>>>>
>>>>> Java server will start read / write to a new DB table every
>>>>> week/monday
>>>>> e.g.
>>>>> table-1-2-2012 table-1-9-2012 table-1-16-2012 table-1-23-2012 ... etc
>>>>>
>>>> What problem are you using table rotation to solve?
>>>>
>>>> What would prevent you from using a single table containing datestamped
>>>> rows which are archived and/or deleted the rows after "cycle length"
>>>> days?
>>>
>>> my main problem is how to make sure "how to get the correct table name
>>> to read/write to" depending what day in the week
>>>
>>> start a new DB table is a must since it's going through some other
>>> REST backend layer
>>
>> There is nothing in REST that requires such a table structure.
>>
>> And it would be better to fix the bad code requiring such
>> a table rollover than to make other apps bad to work with it.
>
> Another question: Jim, what database are you using? If the instance
> requiring multiple tables is afraid of volume the typical solution to
> this issue is called "partitioning". If your database supports it,
> that's typically the way to go for such kind of data.

Yep.

But if one has a database of a size that requires partitioning, then
one better have both app and database specialists inhouse.

Arne

[toc] | [prev] | [next] | [standalone]


#11661

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-01-30 21:35 -0500
Message-ID<4f27535c$0$283$14726298@news.sunsite.dk>
In reply to#11649
On 1/30/2012 9:08 PM, Jim Lee wrote:
> I have a Java server controller that read/write to Database table
>
> Java server will start read / write to a new DB table every
> week/monday
> e.g.
> table-1-2-2012
> table-1-9-2012
> table-1-16-2012
> table-1-23-2012 ... etc

BTW, drop the hyphen in table names it will cause
problems.

Arne

[toc] | [prev] | [next] | [standalone]


#11670

FromLew <noone@lewscanon.com>
Date2012-01-30 22:54 -0800
Message-ID<jg837q$5j9$1@news.albasani.net>
In reply to#11661
Arne Vajhøj wrote:
> Jim Lee wrote:
>> I have a Java server controller that read/write to Database table
>>
>> Java server will start read / write to a new DB table every
>> week/monday
>> e.g.
>> table-1-2-2012
>> table-1-9-2012
>> table-1-16-2012
>> table-1-23-2012 ... etc
>
> BTW, drop the hyphen in table names it will cause
> problems.

and use YYYYMMDD format for sorting purposes if you must be so intransigent on 
the repeated, excellent advice to abandon the approach in favor of a proper 
table design.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

[toc] | [prev] | [next] | [standalone]


#11714

FromGeorge Neuner <gneuner2@comcast.net>
Date2012-02-02 14:05 -0500
Message-ID<ojkli7pu87pc57guh7am8tlvkrmcrfhb7f@4ax.com>
In reply to#11649
On Mon, 30 Jan 2012 18:08:04 -0800, Jim Lee <jimlee2907@yahoo.com>
wrote:

>Java server will start read / write to a new DB table every
>week/monday 
>e.g. 
>table-1-2-2012
>table-1-9-2012
>table-1-16-2012
>table-1-23-2012 ... etc
>
>I think of 2 ways to do the DB table rotation
>
>1) check the server timestamp, if today's date is week of 1-23-2012,
>then read/write to table-1-23-2012 
>
>2) have a unix cron job run every monday to generate a text file on
>Java server with DB table named on that date - on each Java request,
>check the text file's table name - then read/write to that DB table
>
>any other solution to DB table rotation?

Others have already harped on the poor design ... so I'll just address
the question as asked.

1) You don't say what DBMS, but most workgroup and enterprise level
implementations include a built in task scheduler.  You can create a
internal task that runs at a specific time to create new tables.

2) Since you are load balancing, you are (or should!) be using
replication to keep the database instances synchronized.  If you are
doing online (hot) replication, then creating a new table on one
server will replicate it on the other servers within a minute or so.
If, OTOH, replication is periodic, you can kick start it after
creating the new table.

3) You can designate one server as a master and have it remotely
create tables on the other servers.  This also can be done with a DBMS
task.  Of course, this introduces failover issues, i.e. what to do if
the master DBMS instance is down.


Clients do not need to know about or participate in this table
rotation scheme at all.  They can use the same table all the time.
Periodically the contents of the table can be copied into a dated
archive table and then the current use table can be emptied.

This is a simple 2 step transaction:

SELECT INTO <archival table> * FROM <current table>;
DELETE FROM <current table>;

George

[toc] | [prev] | [next] | [standalone]


#11817

FromRajiv Gupta <rajiv@invalid.com>
Date2012-02-08 02:08 +1100
Message-ID<jgreoj$jcp$1@speranza.aioe.org>
In reply to#11649
On 2012-01-31 13:08:04 +1100, Jim Lee said:

> I have a Java server controller that read/write to Database table
> 
> Java server will start read / write to a new DB table every
> week/monday
> e.g.
> table-1-2-2012
> table-1-9-2012
> table-1-16-2012
> table-1-23-2012 ... etc
> 
> I think of 2 ways to do the DB table rotation
> 
> 1) check the server timestamp, if today's date is week of 1-23-2012,
> then read/write to table-1-23-
> 
> 2012

Sir, that sounds really really fucked up.  Why not just one table? 
Tables can store huge amounts of data efficiently.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.java.programmer


csiph-web