Best Partition for Time Series

Hi All,
i have the following tables in my DB
CREATE TABLE READING_DWR (
ID     VARCHAR(20)     NOT NULL,
MACHINE_ID     VARCHAR(20),
DATE_ID     NUMBER,
TIME_ID NUMBER,
READING NUMBER
CREATE TABLE DATE_DIMENSION (
DATE_ID     NUMBER     NOT NULL,
DATE_VALUE     DATE     NOT NULL,
DAY     VARCHAR(10),
DAY_OF_WEEK     INTEGER,
DAY_OF_MONTH     INTEGER,
DAY_OF_YEAR     INTEGER,
PREVIOUS_DAY     DATE,
NEXT_DAY     DATE,
WEEK_OF_YEAR     INTEGER,
MONTH     VARCHAR(10),
MONTH_OF_YEAR     INTEGER,
QUARTER_OF_YEAR     INTEGER,
YEAR     INTEGER
CREATE TABLE TIME_DIMENSION (
TIME_ID     NUMBER     NOT NULL,
HOUR     VARCHAR(3),
MINUTE     VARCHAR(3),
SECOND     VARCHAR(3),
INTERVAL     NUMBER
Referential Constrains:-
STG_READING(DATE_ID)>>>>>DATE_DIMENSION(DATE_ID)
STG_READING(TIME_ID)>>>>>TIME_DIMENSION(TIME_ID)
READING_DWR contains the time series data for a particular machine.
What is the best way to partition the READING_DWR to improve the performance of my select query??

Thanks for posting the additional information. I think I have a better understanding of what you are trying to do.
As I suspected partitioning has nothing to do with it.
>
Now where the first value is null , i have to get the record from the READING_DWR , where the time is less then 10:00 for a particular machIne
>
If I understand what you what you are trying to do correctly it is something like this. Please correct anything that is wrong.
1. READING_DWR is a history table - for each machine_id there is a datetime value and an amount which represents a 'total_to_date' value
2. STG_READING is a stage table - this table has new data that will be (but hasn't been) added to the READING_DWR table. All data in this table has a later datetime value than any data in the READING_DWR table. You know what the date cutoff is for each batch; in your example the earliest date is 10:00
3. You need to report on all records from STG_READING (which has 'total_to_date') and determine the 'incremental-value'; that is, the increase of this value from the preceding value.
4. For the first record (earliest datetime value) in the record set for each machine_id the preceding value will be the value of the READING_DWR table for that machine_id for the record that has the latest datetime value.
5. Your problem is how to best meet the requirement of step 4 above: that is, getting and using the proper record from the READING_DWR table.
If the above is correct then basically you need to optimize the 'getting' since you already posted code that uses the LAG (1 record) function to give you the data you need; you are just missing a record.
So where you show output that was from only the STG table
>
Now the output will be
=======================
Time Reading lag
10:00 200 null
10:15 220 200
10:20 225 220
10:30 230 225
>
If you include the DWR record (and no other changes) the output might look like
>
Time Reading lag
08:23 185 null
10:00 200 185
10:15 220 200
10:20 225 220
10:30 230 225
>
The above output is exactly what you want but without the first record. I assume you already know how to eliminate one record from a result set.
So the process for what you need, in pseudo-code, basically boils down to:
WITH ALL_RECORDS_NEEDED AS (
SELECT machine_id, last_record_data FROM READING_DWR
UNION ALL
SELECT * FROM STG_READING
SELECT lag_query_goes_here FROM ALL_RECORDS_NEEDEDThen either ignore or remove the earliest record for each machine_id since it came from READING_DWR and will have a NULL for the lag value. If you add a flag column to each query to indicate where the data came from (e.g. 'R' for READING_DWR and 'S' for STG_READING) then you can just use the records with a flag of 'S' in a report query or outer query.
So now the problem is reduce to two things:
1. Efficiently finding the records needed from the READING_DWR table
2. Combining the one DWR record with the staging records.
For #1 since you want the latest date for each machine_id then an index COULD help. You said you have an index
>
index on READING_DWR---MACHINE_ID,DATE_ID,TIME_ID
>
But for a query to find the latest date you want DATE_ID and TIME_ID to be in descending order.
The problem here is that you have seriously garbaged up your data by using numbers for dates and times - requiring
>
TO_DATE(DATE_ID||''||LPAD(time_id,6,0),'YYYYMMDDHH24MISS'))
>
to make it useful.
This is a VERY BAD IDEA. If at all possible you should correct it. The best way to do that is to use a DATE column in both tables and convert the data to the proper date values when you insert it.
If that is not possible then you should create a VIRTUAL column using your TO_DATE functionality so that you can index and query the virtual column as if it were a date.
For #2 (Combining the one DWR record with the staging records) you can either just union the two queries together (as in my psuedo-code) or extract a copy of the DWR and insert it into the staging table.
In short query ALL of the DWR records you need (one for each machine_id) separately as a batch and then combine them with the STG records. Don't look them up one at a time like your posted code is trying to do.
If your process is something like this and perhaps run every 15 minutes
1. truncate the stage table
2. run my report
3. add stage records to the history table
Then I would modify the process to use the 15 minutes 'dead' time between batches to extract the DWR records needed for the next batch into a holding table. Once you do step 3 above (update the history table) you can run this query and have the records preprocessed for your next batch and report.
I would use a new holding table for this purpose rather than have the staging table server a double purpose. You never know when you might need to redo the staging table load; this means truncating the table which would wipe out the DWR staged records.
Anyway - with all of the above you should be able to get it working and performing.

Similar Messages

  • I am setting up a time machine backup to a external Hard drive.  I want to backup by Mac book Pro running OSX 10.8.5. I would like to Partition the disk and use one partition for Time machine backups and the other for my Lightroom backups. How to do this?

    I want to create a two partition disk. One partition for time machine, the other for Lightroom backup. Currently Time Machine is using the entire drive and it is doing the intial encryption and is about 29% complete after two days.  I've decided that I want to turn encryption off and partition the disk. So I do I start over?

    With the external drive attached, open Finder>Applications>Utilities>Disk Utility.  Select the external drive from the list in the left side panel of the DU window.  In the main window panel, click Partition in the buttons top center of that panel.
    Select the number of partitions you want and adjust their sizes.
    For the first partition, click to highlight the partition, then select the format, Mac OS Extended (Journaled) and then the partition table as GUID [both of those are the defaults].  Click Apply and it will ask to confirm and erase and format that partion...oh, give the partition a name, like Backup. 
    Then repeat those steps for the second partition..and remember to name it...something like Lightroom.
    Close Disk Utilitty and you are ready to send TM to the one partition, and do your backup of Lightroom to the second partition.

  • How much should I partition for Time Machine/Backup?

    Hi all,
    I upgraded my PB G4 HD to a 160GB recently and have just purchased a 1TB External HD. How much should I partition in the external to be used for Time Machine backup purposes of my internal HD? Will the same size suffice, or should I allocate more?
    Also, I was thinking of formatting the drive so that it's both Windows and OS X friendly, but that means formatting it to MS-DOS something (I was just reading about it in another thread), will that cause any issues for the partition for Time Machine that I created? Thanks.

    Also, I was thinking of formatting the drive so that it's both Windows and OS X friendly, but that means formatting it to MS-DOS something (I was just reading about it in another thread), will that cause any issues for the partition for Time Machine that I created? Thanks.
    That's not practical. If you want to use the hard drive on a Windows machin while still being useful for Time Machine you should use MacDrive.
    I upgraded my PB G4 HD to a 160GB recently and have just purchased a 1TB External HD. How much should I partition in the external to be used for Time Machine backup purposes of my internal HD? Will the same size suffice, or should I allocate more?
    I would make the partition at least twice the size of the internal drive. Preferably, you would want 50 GB for a Leopard install that includes just the base operating system so you can boot off the 50 GB to recover your Time Machine data if your Leopard installer disc ever becomes unusable.
    Also since you have a Powerbook, your 1 TB hard drive should be Firewire. USB will not boot Powerbooks. If it is USB only, you can remove the external hard drive case and replace it with one compatible with the drive inside that case from http://www.macsales.com/ that has Firewire.

  • Just bought a 3TB Time Capsule for a small office. Will have 4 users with MacBooks. What would ne the best setup for time machine individual backups and internet sharing in a secure way?

    Just bought a 3TB Time Capsule for a small office. Will have 4 users with MacBooks. What would ne the best setup for time machine individual backups and internet sharing in a secure way?

    Set up each Mac for Time Machine backups in the normal way.  Time Machine will keep each backup separate on the Time Capsule, so users will only be able to see the backups of their own Mac.
    Yes....there are convoluted workarounds that might allow one user to see the backups of another.....IF...they know the administrator password of the "other" Mac.
    As far as Internet sharing, all users will have access to the Internet if they have a wired or wireless connection. If a Mac connects using wireless, it is possible to limit the time that they are allowed to connect to the network.
    For example, you might limit the ability to connect to the wireless from say each Weekday from 8 AM to 6 PM.
    With a wired Ethernet connection, you cannot limit access times to the Internet.

  • SQL for Time Series Functions AGO and YTD

    When we use a time series function such as AGO or TODATE, OBIEE creates 2 physical queries. One query reads the calendar table. The other query reads the fact table without any date filter in the WHERE clause. Then the results of the 2 queries are stitched together. The query on the fact table returns a lot of rows because there is no filter on date.
    Is there a way to force OBIEE to put a filter on the date when performing the physical query on the fact table when using AGO or TODATE?
    Thanks,
    Travis
    v11.1.1.6

    We do have a date filter on the analysis. We need the analysis to show sales for a certain month and sales for that month a year ago, so we use the AGO function. However, it is really slow because it does a physical query on the sales table without filtering on date and then filters the results of that physical query by the dates from the physical query on the calendar table.

  • Current best practice for Time service settings for Hyper-V 2012 R2 Host and guest OS's

    I am trying to find out what the current best practice is for Time service settings in a Hyper-V 2012 environment. I find conflicting information. Can anyone point me in the right direction. I have found some different sources (links below) but again the
    are not consistent. Thanks
    http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/11/19/time-synchronization-in-hyper-v.aspx
    http://technet.microsoft.com/en-us/library/virtual_active_directory_domain_controller_virtualization_hyperv(v=ws.10).aspx
    http://social.technet.microsoft.com/wiki/contents/articles/12709.time-services-for-a-domain-controller-on-hyper-v.aspx

    From the first link provided by Brian, it does state that the time service should be off, but then the update changes that statement.  Still best to rely on the first link in the OP - it was written by the guy that has been responsible for much of what
    gets coded into Hyper-V, starting from before there ever was a Hyper-V.  I'd say that's a pretty reliable source. 
    Time service
    For virtual machines that are configured as domain controllers, it is recommended that you disable time synchronization between the host system and guest operating system acting as a domain controller. This enables your guest domain controller to synchronize
    time from the domain hierarchy.
    To disable the Hyper-V time synchronization provider, shut down the VM and clear the Time synchronization check box under Integration Services.
    Note
    This guidance has been recently updated to reflect the current recommendation to synchronize time for the guest domain controller from only the domain hierarchy, rather than the previous recommendation to partially disable time synchronization between the
    host system and guest domain controller.
    . : | : . : | : . tim

  • How prepare Query for time series algorithm?

    Hi every one, 
    i want next 6 month prediction, how prepare the Query ,
    I have Date column,Crime column,Incidents Column,I going with next 6 month so how we get date columns month wise or date wise,
    if month wise means,How split the Year and month from date colum??
    Please i need some help.....waiting for reply.....
    pandiyan

    Hi Leo,
    Thanks a lot for replay.
    but using  help of this blog also this problem not solve.
    is this problem can we  solve using  "Seasonal Decomposition of Time Series by Loess".
    Regards,
    Manish

  • What is best stockage for time machine server

    H i hello
    I want make a time machine server for backup all macs in my network
    I have mountain lion server, and i want know what is the best solution for stockage for time Machine
    Nas ? San ?
    Can i use NTFS with time machine ? CIFS ? or just AFP ?
    Thanks you for your help

    Welcome to the Apple Support Communities
    Any modem will work. Note that you will only use your modem to connect your Time Capsule to it using an Ethernet cable, and it will bring the Internet connection to the Time Capsule, so all modems do the same

  • External hard drive partition for Time Machine wont mount

    I have an external HD that I've partitioned half for Time Machine, and half for external storage. Today the Time Machine partition wouldn't show up on the desktop. I checked Disk Utility and it recognizes both partitions, but the Time Machine partition is greyed out. When I selected it, in the stat list at the bottom it said "Mount Point: Not Mounted." I then clicked on "Mount" at the top, and after a bit a popup told me it couldn't mount and I should attempt to repar the disk. So I clicked "Repair Disk," and after a while, I finally got the message "Error: Disk Utility can’t repair this disk. Back up as many of your files as possible, reformat the disk, and restore your backed-up files."
    Why is only one partition affected? Can I reformat one petition but leave the other untouched? Are there any other options before I do this?
    One other item that is probably related: I've been having an issue with a flash drive that seems to constantly unmount itself, giving me "error, disk ejected improperly" messages. Earlier today I believe I had the same thing with my external HD.

    Why is only one partition affected?
    The drive malfunction that caused the problem only affected that partition.
    Can I reformat one petition but leave the other untouched?
    Yes.
    Are there any other options before I do this?
    This is not an option, it's mandatory: start a new backup on another drive. The one you have has lost data once already. If it were mine, it would be in the recycling bin now. You need more than one backup to be safe anyway. Apparently you have no backups at all of the data on the other partition. That means you're going to lose that data, sooner or later.

  • External drive partitions for Time Machine

    Questions:
         1.  Do I need to have a two partitions on my external hard drive, one each for my iMac and another for my MBPro?
       2. Do I need to partition to use both Time Machine and SuperDuper or Carbon Copy Clone.?
       3. Which is better to use for backup if you need or want to retrieve a specific file?
    Thanks for your help.
    Vernon

    1. No. Configure each machine's Time Machine preferences separately. Time Machine will take care of the rest.
    2. Yes. You must clone to a freshly formatted drive or partition on a drive. I suggest you use two separate drives. One for Time Machine and the other for the clone. This way you have a good backup in case one fails.
    3. I don't understand the question. Which "what" are you referring to? If you mean choosing between Time Machine and a clone, it's better to have one of each. The more backups the better.

  • Need advice on best approach for Time Machine on Macbook

    I have several external disks attached to my iMac, one of which is the Time Machine disk for that computer. I just got a Macbook for my wife and I am trying to figure out the best way to use Time Machine with it. I am thinking the easiest would be to add another external hard disk to my iMac, make it sharable and have the Macbook Time Machine backup over the wireless network to that disk. That way it can back up no matter where it is in the house.
    But I am new enough to the Mac that I don't know if that is 1) possible 2) the easiest. I got the sense that I could buy an Airport and attach a hard disk to that but it seemed like a kind of expensive solution.
    Any comments/ideas? I am trying to do this as simply as possible without it costing a bunch.

    bobmcgraw
    Yes, in theory. This is exactly how i have been using time machine... however I have just come up against a major issue with this.
    I was backing up my Macbook Air, by using a drive attached to my iMac, and the iMac was sharing the drive. I could happily connect, and configure time machine on the Macbook to use the drive, and away it went.....
    Looking at the drive itself, I had a folder for my imac backups... and for the Macbook there was a 'sparsebundle' image.
    All seemed well, and Time Machine functioned as expected on the Macbook Air.
    The problem occurred when I decided to replace my Macbook Air with a new macbook. Once I had set up the new machine, I thought I could use the time machine backup to restore the new macbook with the old macbook Air's details (in much the same way as I would assume that I could restore back to a new unit if the old machine had failed).
    Even with the time machine volume mounted on the new Macbook, the 'sparsebundle' Macbook air was simply not recognised as a backed up machine. Whenever I tried to use the migration assistant to restore back my data, the ONLY time machine backup that it would find on my Time Machine drive was the iMac's one... not the Macbook Air's.
    So.... in short... If you chose this option, It is fine for backing up, and restoring as far as it goes... but beware if you ever need to restore the machine in its entirety using migration assistant or the like - as it doesn't seem to work.
    Now I have discovered this, I really need to re-think my setup - perhaps share the volume by plugging it into my Airport Extreme Base Station.
    The unfortunate situation is that the current backup is absolutely useless in its present form, as one of the things I need to protect myself against is machine failure,and I need to be able to restore a new machine to look like the old one. In this situation I was able to connect BOTH old and new macbooks to the network, and use migration assistant to migrate from one to the other. All was well there, but this would not have been an option if I did not have access to both machines.

  • Best approach for Time Machine / Entourage / FileVault / sparse bundle disk

    I am looking to set up Time Machine belatedly on my G5 to provide hassle-free backup for me and my family. I use Entourage. I also want to provide a small amount of encrypted storage. I’ve scoured the obvious places which have plenty of ideas, but nothing which pulls it all together.
    My thoughts so far have been:
    1. Time Machine doesn’t work well with Entourage as Entourage uses a monolithic single file (which in my case is several GB big) – backing this up every hour will bring my machine to its knees, fill up the backup disk and will possibly give a corrupt backup as the file could be accessed by Entourage or the MS daemon process during the backup.
    2. I thought of turning FileVault on which would automatically contain the Entourage file. This would mean:
    a) the sparse bundle format (8 MB bands) of FileVault would limit the volume of changed Entourage data which would be backed up each time by Time Machine and
    b) the backup would only occur during logout (which is fine with me) when Entourage and the MS daemon are not running so that the backup won’t be corrupt.
    3. However I am not hearing good things about the reliability of FileVault (comments?) and don’t want all the data in my Home folders lost – I don’t need that much encryption anyway.
    4. So I thought about setting up a couple of encrypted disk images made of sparse bundles – one for the Entourage data (symbolically linked to the right place for Entourage to pick the folder up) and the other for the other small number of files I need encrypted. This could be auto-mounted at login.
    5. However I think that using disk images rather than FileVault loses the automatic backup by Time Machine at logout. Maybe there is a way to get Time Machine to automatically backup these disk images during logout.
    6. Perhaps there is another way to get the disk images backed up at logout other than using Time Machine.
    So my questions are:
    A. What is the best overall approach to providing a low-maintenance reliable backup which deals appropriately with Entourage and provides a small amount of encrypted space?
    B. Can Time Machine be made to backup disk images other than FileVault disk images at logout? (for example is there a particular location / filename format for FileVault images which I could emulate with the other disk images to fool Time Machine into backing them up?)
    C. When Time Machine runs at logout, have MS Entourage and the daemon process already been shut down and the disks unmounted, to prevent corruption?
    D. Is there another way of backing up the sparse image disks at logout?
    C. Is this all going to get magically fixed in Snow Leopard?
    D. Will MS come up with a sensible storage format for Entourage?
    Any thoughts greatly appreciated.

    I don't know if there is a complete solution, but here are some things you could consider.
    1. TM does not run automatically at logout unless FileVault is enabled.
    2. You can change the backup period using third-party utilities like TimeMachineEditor - VersionTracker or MacUpdate.
    3. You can exclude the Microsoft User Data folder from the TM backup and back it up separately using third-party backup software.
    4. You can use third-party backup software instead of TM, such as:
    1. Retrospect Desktop (Commercial - not yet universal binary)
    2. Synchronize! Pro X (Commercial)
    3. Synk (Backup, Standard, or Pro)
    4. Deja Vu (Shareware)
    5. Carbon Copy Cloner (Donationware)
    6. SuperDuper! (Commercial)
    7. Intego Personal Backup (Commercial)
    8. Data Backup (Commercial)
    9. SilverKeeper 2.0 (Freeware)
    10. Tri-Backup (Commercial)
    11. Apple Backup (requires a .Mac account with Apple both to get the software and to use it.)
    Apple's Backup is a full backup tool capable of backing up across multiple media such as CD/DVD. However, it cannot create bootable backups. It is primarily an "archiving" utility.
    Visit The XLab FAQs and read the FAQ on backup and restore. Also read How to Back Up and Restore Your Files.
    Third-party backup utilities can run backups on schedules you set up. Thus, you can schedule your backups to occur at a time when you do not use the machine such as early in the AM for example.

  • Best Methods for Time, Tempo and Rhythm Alignment?

    Hello All, I am looking to edit some lengthy jams to concise segments. I wish to mix and match audio tracks (ex. drum section from begining with bass section in middle with guitar section at end). No metronome was used, so while the general structure (melody and rhythm) remained similar, tempos vary so that the parts don't match up perfectly. I know Logic has some pretty powerful time-based editing capabilities through its flex mode, but i am confused where the logical starting point would be for my situation. Do you think it would be to first chop up segments, pick a q-reference, set a global tempo, stretch or compress segments, and then individually correct any remaining rhythm alignment issues? What do you think are the best methods to accomplish this? I hope my questions are clear - if not please tell me. Thanks to anyone who cares and can help!
    JS

    Matt Woodward has some sample code on his blog to use the
    asyncronous event gateway to send email. The post is here :
    http://mattwoodward.com/blog/index.cfm?commentID=203
    This should take care of your timeout issues...
    Ross Valenti
    <edited to fix misspelled name >

  • Making partition for Time Machine

    I have a 500 drive and I'd to configure Time Machine to use 350 GB for backups, and use the rest for regular storage, how can I do that?

    yes - use disk utility to partition the drive (this will erase all the contents of the drive so be sure to backup any thing on it that you want to save) and have TM use the 350 partition (what size is your source drive and how much storage do you have on it to backup?)
    LN

  • PCs won't recognise my HDD after formatting partition for TIME MACHINE

    Hi,
    I divided my WD Passport HDD in 2 250GB partitions, to work both with TIME MACHINE and also as an archive to share files and folders with other computers. Time machine has now backed up my system, but as I plugged the HDD in my PC it won't recognise it... I mean, it recognises that a USB storage device has been connected, but then it won't show in My Computer.
    What can I do? does anyone know if there is any ways that I can keep my archive partition compatible with Windows?
    thanks,
    Fra

    Hi Fra and welcome to Discussions,
    I assume that your archive partition is using 'Mac OS Extended (journaled)' as file system, correct ?
    If so, only MacDrive http://www.mediafour.com/products/macdrive/ can help Windows to see and use this partition.
    If you use FAT32 (a.k.a. MS-Dos in Disk Utility) or NTFS as file system on your archive partition, there are reports of Windows PCs not being able to see/use harddisks that uses GPT (GUID Partition Table - standard on Intel Macs).
    You could solve this by reformating/repartitioning your external harddisk using MBR (Master Boot Record) as partition scheme, but not only will this erase all informations that are on your external harddisk right now, it will also prevent Time Machine from using this harddisk.
    So, this is not a viable option for you.
    Regards
    Stefan

Maybe you are looking for

  • TS1398 My iPhone 4S will no longer connect to wifi.  Please help

    My iPhone will no longer connect to wifi.  Please help! I've tried turning it off, restarting, etc. 

  • Backup with Time capsule and external HD

    I have a harddrive to backup to but when I choose it, a message comes up saying it is going to remove everything from the HD before backup and is that ok....no...it's not ok...do I need a backup specific harddrive?

  • Update 1.1.1

    i need help....i just downloaded the new update to my ipod. How will I know when the update/restore is complete? I saw the apple logo come up on the ipod, but the screen now says do not disconnect. The updater window shows my name, the serial number,

  • ORA-13044: the specified tile size is smaller than the tolerance

    Hi, I get the oracle error ORA-13044: the specified tile size is smaller than the tolerance when I do the following point cloud clip: 8 sdo_geometry(2003,29903, null, 9 mdsys.sdo_elem_info_array(1,1003,3), 10 mdsys.sdo_ordinate_array(316504,316510,23

  • Duplicate Application Appearing in Applications Tab

    I have several applications that I have purchased for my iPhone, one of these applications (Fizz Weather) appears twice in the Applications Tab in iTunes. If I right click and delete one of the icons it always reappears when I shut down and restart i