w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
After new partition gets created insert partition info in another table through trigger
You can do it with DDL Trigers. Check out this link One important note from the author you should consider adding a partition is not DDL if Oracle decides to do it internally, it’s only DDL if it’s an end-user statement Implicit partition creation is a new feature of 11g and it reffers to the interval partition option.

Categories : Oracle

Hoare partition : is this implementation more/less efficient than the standard partition algorithm?
I always prefer the standard Hoare's implementation. If you look at it, it is not very intuitive, but it has a visible advantage: Less number of swaps. While your implementation effectively always does exactly N comparisons and N swaps, the Hoare's implementation does only N comparisons, but it does not swap anything if it is not needed. The difference is significant in some scenarios. At first in a case you use environment where swaps or assignment of variables/objects is a costy operation. For example if you use C/C++ with arrays of objects. Another typical examples where Hoare's partition implementation performs better if when many of the items in your array are of the same value or when the array is almost sorted and needs just to swap a few items. In that cases Hoare's version perfor

Categories : Matlab

MySQL table Partition with FLOOR function (partition function not allowed)?
MySQL documents the partitioning functions here. The floor() function appears to have some special considerations. In this case, I think the issue might be that the division is returning a float/double result rather than a decimal result. This is easily fixed in your case because you do not need to do the division: CREATE TABLE `fact_events` ( `event_key` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `event_type_key` tinyint(3) unsigned NOT NULL, `analytic_file_id` bigint(20) unsigned NOT NULL, `sdk_session_id` bigint(20) unsigned NOT NULL, `virtual_button_create_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`event_key`), KEY `idx_events_event_type` (`event_type_key`) ) PARTITION BY RANGE(event_key) ( PARTITION p0 VALUES LESS THAN (0), PARTITION

Categories : Mysql

SUM OVER PARTITION BY
remove partition by and add group by clause, SELECT BrandId ,SUM(ICount) totalSum FROM Table WHERE DateId = 20130618 GROUP BY BrandId

Categories : SQL

How should I partition this table?
I suggest Sharding the database. More information can be found here importance of sharding and approaches towards MySQL sharding. Hope this helps.

Categories : Mysql

Only get the partition label
As far as I know, Get-PSDrive doesn't know the difference betwee network and local drive. You can use Get-WMIObject Win32_LogicalDisk, which supports filtering drives by type. Filtering example: Get-WmiObject Win32_LogicalDisk | select-object DeviceID, DriveType, @{Name="Type";Expression={[IO.DriveType]$_.DriveType}} | ? {$_.Type -eq 'Fixed'} or Get-WmiObject Win32_LogicalDisk | ? {$_.DriveType -eq 3}

Categories : Powershell

Why only one active partition in MBR
Wikipedia has a nice article on MBR with a lot of useful links. "Only one active partition" seems to be a design choice from the early IBM/DOS bootloader, and has remained that way since. Basically they defined multiple active partitions as an error, and checked for this error at boot. It kind of makes sense because you can only boot one operating system at a time anyway, and a forced single active partition will prevent ambiguity. If I recall correctly LILO and possibly GRUB (linux bootloaders) don't mind if there are multiple active partitions, so I think this is a DOS/Windows issue mostly. As for your questions. An "active" partition only means that the first byte is different from an "inactive" partition. There's no advantage or disadvantage, it's just a flag. Partition information

Categories : Misc

how do I give partition in the
Here is mark-up for the layout you describe (without all the style - just the layout)... <ul class="menu"> <li><a href="/home">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/songs">Songlist</a></li> </ul> And the CSS ul.menu { margin: 0; padding: 0; text-align: center; } ul.menu li { display: inline-block; width: 33%; } ul.menu a { display: block; width: 100%; padding: 0.2em 0; }

Categories : HTML

Cassandra: choosing a Partition Key
Indexing in the documentation you wrote up refers to secondary indexes. In cassandra there is a difference between the primary and secondary indexes. For a secondary index it would indeed be bad to have very unique values, however for the components in a primary key this depends on what component we are focusing on. In the primary key we have these components: PRIMARY KEY(partitioning key, clustering key_1 ... clustering key_n) The partitioning key is used to distribute data across different nodes, and if you want your nodes to be balanced (i.e. well distributed data across each node) then you want your partitioning key to be as random as possible. That is why the example you have uses UUIDs. The clustering key is used for ordering so that querying columns with a particular clusteri

Categories : Cassandra

Partition using Lead in Oracle
As one of the approaches, we can do the following: with cte(key, book, prd_key, direction, trdtime, price, grp) as( select t.* , dense_rank() over(order by t.trdtime desc) from trd t ) select q.key , q.book , q.prd_key , q.direction , q.trdtime , q.price , grp , (select max(c.price) from cte c where q.direction <> c.direction and c.grp = (select min(grp) from cte l where l.direction <> q.direction and l.grp > q.grp ) ) as next_price from cte q Result: Key Book Prd_Key Direction Trdtime Price Next_Price ------------------------------------------------------

Categories : Oracle

SQL "over" partition WHERE date between two values
row_number() operates after where. You'll always get a row 1. For example: declare @t table (id int) insert @t values (3), (1), (4) select row_number() over (order by id) from @t where id > 1 This prints: 1 2

Categories : SQL

Add sub partition on another column in oracle
No alter query for adding subpartitions as far as i know. To get the desired result performe the folowing steps Create the table in the structure you want using create as select with the partitions and the sub partitions. switch the names of the two tables. you can also explore the use of dbms_Redefinition but if you have a luxury of a littel downtime it's not worth it.

Categories : Oracle

Inconsistent SUM when using OVER PARTITION in MSSQL
For floating point arithmetic the order that numbers are added in can affect the result. But in this case you are using Decimal(12,2) which is precise. The issue is that with duplicate values for nGroup, nUser, dTransaction the ROW_NUMBER is not deterministic so different runs can return different results. To get deterministic behaviour you can add guaranteed unique column(s) into the end of the ORDER BY to act as a tie breaker.

Categories : Sql Server

Parallelizing std::nth_element and std::partition
Cuda THRUST has partition function implemented (http://docs.nvidia.com/cuda/thrust/index.html#reordering). The main idea should be following: Using prefix sums to calculate position of element it the array and then rearrange the array.

Categories : C++

Assigning a letter to OEM Partition
Partitions are storage units used to divide physical disks into smaller, independent parts. Basically they're containers for filesystems. Volumes are storage units with a filesystem. A volume can be inside a partition, but it's also possible for a volume to span multiple partitions. As for assigning a drive letter to that particular partition: you need to determine the type of the filesystem inside that partition first. GParted might prove helpful there. Windows can only mount FAT(32) and NTFS volumes. For other filesystems (like Ext2/3/4 or XFS) you're going to need 3rd party tools.

Categories : Powershell

PARTITION BY doesn't work in H2 db
I don't think H2 supports window functions (aka analytic functions). However, you can do the query in the link using standard SQL: SELECT t.* FROM yourtable t join (select vendorname, max(incidentdate) as maxdate from yourtable yt group by vendorname ) vn on vn.vendorname = yt.vendorname ORDER BY vn.maxDate DESC, t.VendorName ASC, t.IncidentDate DESC; Although this should run in both environments, the over form probably performs better in SQL.

Categories : Oracle

SQL Server Switch more than one Partition at once
Not that I'm aware of. What I'd typically do is place the switch inside the loop. Something like this: DECLARE @Partitions TABLE (PartitionId int PRIMARY KEY CLUSTERED); DECLARE @PartitionId INT; INSERT @Partitions(PartitionId) SELECT prv.boundary_id PartitionId FROM sys.partition_functions AS pf INNER JOIN sys.partition_range_values prv ON prv.function_id=pf.function_id WHERE (pf.name=N'PartitionFunctionName'); WHILE EXISTS (SELECT NULL FROM @Partitions) BEGIN SELECT TOP 1 @PartitionId = PartitionId FROM @Partitions; ALTER TABLE MS_PROD SWITCH PARTITION @PartitionId TO MS_Stage PARTITION @PartitionId; RAISERROR('Switched PartitionId %d to Stage',0,1,@PartitionId) WITH NOWAIT; DELETE @Partitions WHERE PartitionId = @Parti

Categories : Sql Server

Find partition size using df and awk
You can use sed instead of awk again: df -h | grep "/partition" | awk '{print $3}' | sed -e 's,[A-Z]$,,' Keep in mind that this (and your one-liner) does not print the size of the partition, but the size used.

Categories : Linux

Partition by consecutive values
You need to group rows by sets of operation. One method is to use a running total that increases when it reaches a new "set", as in: SQL> SELECT mat, op, dt, 2 SUM(change_set) over (PARTITION BY mat ORDER BY dt) set_group 3 FROM (SELECT mat, op, dt, 4 CASE WHEN op != lag(op) over (PARTITION BY mat 5 ORDER BY dt) 6 THEN 1 7 END change_set 8 FROM DATA); MAT OP DT SET_GROUP ----- ---------- ----------- ---------- M1004 100 25/08/2013 M1004 100 25/08/2013 M1004 100 29/08/2013 M1004 600 29/08/2013 1 M1004 600 30/08/2013 1 M1004 600 30/08/2013 1 M1004

Categories : SQL

Pig Latin Partition By clause
What is the use of "Partition By" clause in Pig Latin? This allows you to set the Partitioner of your choice. Pig uses the default one i'e HashPartitioner except for order and skew join. But sometimes you might wanna have your own implementation to enhance the performance. Partition By helps there. Also please provide an example usage. DATA = LOAD '/inputs/demo.txt' using PigStorage(' ') as (no:int, name:chararray); PARTITIONED = GROUP DATA by name PARTITION BY org.apache.pig.test.utils.SimpleCustomPartitioner parallel 2; Does it allow only custom partition or allows partition by column? It is just to specify custom partitioners and not to partition directly based on some field. See PIG-282 for more details.

Categories : Hadoop

Partition an array with this algorithm
Say you start with an array a with length l. Then you should create two arrays lesser and greater with l-1 length (since all values could be smaller or larger than the pivot). double[] lesser = new double[a.length() - 1]; double[] greater = new double[a.length() - 1]; After that, it is simply (as in your exercise) copying the data to these arrays. Keep track of the length of both arrays like lesserlength = 0; greaterlength = 0; and incrementing that each time you insert a value. That way you know where you can insert the next value in lesser and greater. Eventually you can copy lesser into a new array of length l. double[] result = new int[a.length()]; You know that lesserlength + 1 + greaterlength == a.length() You can use System.arraycopy(source, srcpos, dest, dstpos, len) to

Categories : Java

using different storage engines per partition
I would suggest having two separate tables, one for your archives and one for your working set. I don't think MySQL views are smart enough to optimize this. It would also give you complete control over the schema but puts the burden on your application.

Categories : Mysql

Array Partition with pointer
A pointer to a pointer is not the same as an array of arrays. You can however use a pointer to an array instead: const char (*pointer)[20]; You of course need to update the printGrid function to match the type. As for the reason why a pointer-to-pointer and an array-of-array (also often called a matrix) see e.g. this old answer of mine that shows the memory layout of the two.

Categories : C++

How to partition a list in Haskell?
Here's one option: partition :: Int -> [a] -> [[a]] partition _ [] = [] partition n xs = (take n xs) : (partition n (drop n xs)) And here's a tail recursive version of that function: partition :: Int -> [a] -> [[a]] partition n xs = partition' n xs [] where partition' _ [] acc = reverse acc partition' n xs acc = partition' n (drop n xs) ((take n xs) : acc)

Categories : Haskell

Linq2SQL Help Converting row_number and partition
You can get the same results with following LINQ query: from o in Orders group o by o.clientId into g select g.OrderByDescending(x => x.purchasedate).FirstOrDefault(); but it will not generate the same SQL. It will use CROSS APPLY instead.

Categories : C#

How to populate Oracle partition table
To insert data from a procedure into your table, you could use code that looks like CREATE OR REPLACE PROCEDURE my_filler AS BEGIN FOR i IN 1 .. 500000 LOOP -- compute your idper, descrizione, dins and then insert into the table INSERT INTO tbigp (idper, descrizione, dins) VALUES (x, y, z); IF MOD(i, 10)=0 THEN dbms_application_info.set_module('my_filler', 'i='||i); COMMIT; END IF; END LOOP; END my_filler; / Having said that, this will be very, very slow. I wouldn't advice to fill it with a procedure commit after 1000 rows

Categories : Oracle

Filtering within an window function (over ... partition by)?
If you're open to anything other than an analytic SUM() then here is a possible solution with a simple correlated subquery SELECT s.item, s.month month_begin, s.sales, (SELECT SUM(sales) FROM sales WHERE month BETWEEN DATEADD(month, -12, s.month) AND DATEADD(month, -1, s.month)) ttm_sales FROM sales s WHERE s.month BETWEEN '20120101' AND '20121201' Sample output: | ITEM | MONTH_BEGIN | SALES | TTM_SALES | ----------------------------------------------------------------- | Item A | January, 01 2012 00:00:00+0000 | 3 | 87 | | Item A | February, 01 2012 00:00:00+0000 | 4 | 88 | | Item A | March, 01 2012 00:00:00+0000 | 5 | 87 | | Item A | April, 01 2012 00:00:00+0000 | 6

Categories : SQL

Can we have partitions within partition in a Hive table?
Hive supports multiple levels of partitioning. But keep in mind that having more than a single level of partitioning in Hive is almost never a good idea. HDFS is really optimized for manipulating large files, ~100MB and larger. Each partition of a Hive table is a HDFS directory. There are normally multiple files in each of these directories. You really should be closing on a petabyte of data to make multiple levels of partitioning in a Hive table. What problem are you trying to solve? I'm sure we can find a sensible solution for it.

Categories : Misc

Good practice to code partition
Validation normally belongs to the service layer, as there is no need to tie it to a specific view implementation. So in your case try to put it in the EJB. If you have to implement another application which is to use another view implementation like Swing for example, it will benefit from the validation as well. It's normally easier to write tests against the service layer; and this way you can test the validation without having to mock the view layer. Using JSF, if you have two use cases using different managed beans, and both use cases create a user, chances are that you end up with writing the validation code twice.

Categories : Java

MySQL Partitioning: why it's not taking appropriate partition
The HASH partitioning scheme means MySQL translates your arbitrary numerical value into its own hash value. You have defined 366 partitions. What do you think would happen if your query were: EXPLAIN PARTITIONS SELECT * FROM temp where PartitionID = 400 ? Your PartitionID cannot mean in this case the real partition's ID/name, since there is no partition 400. Now, just between the two of us, you might be interested to learn that MySQL's HASHing function is a simple modulus. Thus, 0 maps to partition p0, 1 maps to partition p1, and 400 maps to partition 34 (== 400-366). Generally speaking you should not be too interested in the identify of the particular partition being used. You should be more interested to know that there is a good balance of partitions. If the balance doesn't seem ri

Categories : Mysql

How does oracle manage a hash partition
A hash is not random, it divides the data in a repeatable (but perhaps difficult-to-predict) fashion so that the same ID will always map to the same partition. Oracle uses a hash algorithm that should usually spread the data evenly between partitions.

Categories : Oracle

How do I partition in hive by a specific column?
In Hive each partition corresponds to a folder in HDFS. You can reload the data from your unpartitioned Hive table into a new partitioned HIve table using a create-table-as-select (CTAS) statement. See https://cwiki.apache.org/Hive/languagemanual-ddl.html#LanguageManualDDL-CreateTable for more details.

Categories : Hadoop

Azure Table Storage Partition Key
Answering #1: There is no concept of a server that a particular table entity lives on. There are no particular servers to choose from, as Table Storage is a massive-scale multi-tenant storage system. So... there's no way to retrieve a server ID for a given table entity. Answering #2: Choose a partition key that makes sense to your application. just remember that it's partition+row to access a given entity. If you do that, you'll have a fast, direct read. If you attempt to do a table- or partition-scan, your performance will certainly take a hit.

Categories : Azure

Partition and Composition (combinatorics) implementation in C++
Recursive version Here is a recursive solution. You have a sequence a where you keep track of the numbers you already have set. Each recursive call will assign valid numbers to one of these elements in a loop, before recursively calling that function for the remainder of the list. void recurse(std::vector<int>& a, int pos, int remaining) { if (remaining == 0) { print(a); return; } if (pos == a.size()) { return; } for (int i = remaining; i >= 0; --i) { a[pos] = i; recurse(a, pos + 1, remaining - i); } } void print_partitions(int sum_val, int n) { std::vector<int> a(n); recurse(a, 0, sum_val); } Proof of concept run visible at http://ideone.com/oJNvmu. Iterative version Your comment below indicates a performance problem. While it seems very likel

Categories : C++

How to write a quicksort partition function
Here's one problem: int pivot = numbers[(rhs - lhs) / 2]; Suppose lhs = 100 and rhs = 120. The above will choose element (120 - 100) / 2 = 10 as the pivot! I think you want something like int pivot = numbers[(rhs + lhs) / 2]; which will at least choose a pivot from within the range you're trying to partition!

Categories : Java

CoreGraphics: Mass image partition
This is what we call a "tradeoff". You complain that +[UIImage imageNamed:] makes things faster but uses more memory, and that +[UIImage imageWithContentsOfFile:] is slow but doesn't use as much memory. The reason the latter is slow is that every time you call +[UIImage imageWithContentsOfFile:] it has to read and decode the image from "disk" and that takes time (a non-trivial amount of time, as you've learned). When you use +[UIImage imageNamed:] it is read and decoded once, and then the result of the read/decode operation is kept in memory until a memory warning comes in. This means that subsequent accesses of that image (before a memory warning) will be fast. It sounds like a good approach would be for you to cache the images in a cache whose lifetime you can control. NSCache would be

Categories : IOS

Oracle - Doing an update with an Inner Join and Partition?
The laziest approach is to select rowids from your query, and do something like this: UPDATE hist SET .... WHERE rowid IN ( your query ) I created SQLFiddle demo to demonstrate this. The query might look like: UPDATE hist set to_date = sysdate where rowid in ( select hist_rowid from ( select rowid hist_rowid, mgroup, from_date, to_date, rowNumber from ( select mgroup, from_date, to_date, activestatus, row_number() over ( partition by mgroup order by to_date desc nulls first) rowNumber from hist ) where rowNumber = 1 ) hist join "GROUP" ON hist.MGROUP = "GROUP".id AND "GROUP".ACTIVESTATUS = 'Inactive' ); GROUP is reserved word in Oracle,

Categories : SQL

SQL max() over(partition) returning multiple results
I was taking the max of mt.version and partitioning it by mt.version so I wasn't getting any new data. A correct version of what I previously wrote could be: select *, max(mt.version) over (partition by mt.partitiongroup) from mytable mt where mt.id = 'some uuid'; I wasn't realizing while trying out this new concept that the partition group had to be different than the max aggregation.

Categories : SQL

PostgreSQL cannot drop index on partition
Could be related to your search_path. Try dropping the index prefixed by the schema. Eg. SELECT schemaname,tablename,indexname FROM pg_indexes WHERE indexname = 'my_index_name' Using the results of that query, drop the index: DROP INDEX some_schema.your_index_name;

Categories : Postgresql

Getting mapreduce.task.partition in CDH4
Besides shipping with YARN, CDH4 includes hadoop-0.20 which uses the key mapred.task.partition instead of mapreduce.task.partition(from 0.21). Changing it back to the former fixed my problem.

Categories : C++



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.