Hive Sort Merge Bucket Map(SMB Map) Join - join

I ran the query with and without SMB join and got different results. Please help explain.
SET hive.enforce.bucketing=true;
create table dbaproceduresbuckets (
owner string ,
object_name string ,
procedure_name string ,
object_id double ,
subprogram_id double ,
overload string ,
object_type string ,
aggregate string ,
pipelined string ,
impltypeowner string ,
impltypename string ,
parallel string ,
interface string ,
deterministic string ,
authid string )
CLUSTERED BY (object_id) SORTED BY (OBJECT_ID ASC) INTO 32 BUCKETS;
CREATE TABLE dbaobjectsbuckets1(
owner string,
object_name string,
subobject_name string,
object_id double,
data_object_id double,
object_type string,
created string,
last_ddl_time string,
timestamp string,
status string,
temporary string,
generated string,
secondary string,
namespace double,
edition_name string) CLUSTERED BY (object_id) SORTED BY (OBJECT_ID ASC) INTO 32 BUCKETS;
**** load the table;
0: jdbc:hive2://xxxxxx:10000> select count(*) from dbaobjectsbuckets1 a, dbaproceduresbuckets b
0: jdbc:hive2://xxxxxxxx:10000> where a.object_id = b.object_id;
INFO : Hadoop job information for Stage-2: number of mappers: 3; number of reducers: 1
INFO : 2016-06-13 15:56:00,381 Stage-2 map = 0%, reduce = 0%
INFO : 2016-06-13 15:56:55,818 Stage-2 map = 1%, reduce = 0%, Cumulative CPU 122.6 sec
INFO : 2016-06-13 15:57:47,124 Stage-2 map = 7%, reduce = 0%, Cumulative CPU 326.86 sec
..........
INFO : 2016-06-13 16:05:01,246 Stage-2 map = 100%, reduce = 100%, Cumulative CPU 867.1 sec
INFO : MapReduce Total cumulative CPU time: 14 minutes 27 seconds 100 msec
INFO : Ended Job = job_1464280256859_0146
+--------+--+
| _c0 |
+--------+--+
| 54876 |
+--------+--+
****
set hive.auto.convert.sortmerge.join=true;
set hive.optimize.bucketmapjoin=true;
set hive.optimize.bucketmapjoin.sortedmerge=true;
set hive.auto.convert.sortmerge.join.noconditionaltask=true;
set hive.enforce.bucketing=true;
set hive.enforce.sorting=true;
0: jdbc:hive2://xxxxxxx:10000> select count(*) from dbaobjectsbuckets1 a, dbaproceduresbuckets b
0: jdbc:hive2://xxxxxxxx:10000> where a.object_id = b.object_id;
in the execution plan, I am seeing
| Sorted Merge Bucket Map Join Operator |
| condition map: |
| Inner Join 0 to 1 |
| keys: |
| 0 object_id (type: double) |
| 1 object_id (type: double)
**** but the result is showing
INFO : Hadoop job information for Stage-1: number of mappers: 32; number of reducers: 1
......
INFO : MapReduce Total cumulative CPU time: 4 minutes 8 seconds 490 msec
INFO : Ended Job = job_1464280256859_0150
+------+--+
| _c0 |
+------+--+
| 2 |
+------+--+
????? My question is why it only got 2 when I used SMB join?????? It is supposed to be 54876.
Thanks!

use sort by clause while inserting data into sorted table
or
set hive.enforce.sorting=true
before inserting data into sorted table

Related

Aggregate function sum() and count(Distinct()) takes more than minute to return result in influxsql

I am executing one influxSQL query which is returning result in more than 1 minutes.
Query :
select SUM(call_duration) as total_duration,Count(Distinct(recipient_id)) as total_recipients from xyz where target_id = '1';
Separate queries like
select Count(Distinct(recipient_id)) as total_recipients from xyz where target_id = '1';
select SUM(call_duration) as total_duration from xyz where target_id = '1';
are also takes more than 1 minutes to result the return .
while query
select MAX(call_duration), MIN(call_duration) from xyz where target_id = '1';
Return results very fast, in seconds like 3-4 seconds.
table(measurements) xyz is very large. there are more than 10 million records that matches this where condition.
call_duration and recipient_id are Fields while target_id is Tag
While MIN and MAX function returning results very fast, i suspect why SUM is taking more time?
InfluxDB version: 1.7.4
Machine Configuration - AWS EC2 - t2.medium (4 GB RAM)
Config file:
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
series-id-set-cache-size = 100
[coordinator]
[retention]
[shard-precreation]
[monitor]
[http]
enabled = true
auth-enabled = true
log-enabled = true
access-log-path = "/var/log/influxdb/http_access.log"
write-tracing = false
max-body-size = 0
max-concurrent-write-limit = 0
[logging]
[subscriber]
[[graphite]]
[[collectd]]
[[opentsdb]]
[[udp]]
[continuous_queries]
[tls]
I think that result should returned in 5-6 seconds
EXPLAIN select MIN(call_duration) from xyz where target_id='1';
QUERY PLAN
----------
EXPRESSION: min(call_duration::float)
NUMBER OF SHARDS: 21
NUMBER OF SERIES: 85134
CACHED VALUES: 0
NUMBER OF FILES: 24642
NUMBER OF BLOCKS: 31608
SIZE OF BLOCKS: 65520278
EXPLAIN select MAX(call_duration) from xyz where target_id='1';
QUERY PLAN
----------
EXPRESSION: max(call_duration::float)
NUMBER OF SHARDS: 21
NUMBER OF SERIES: 85134
CACHED VALUES: 0
NUMBER OF FILES: 24642
NUMBER OF BLOCKS: 31608
SIZE OF BLOCKS: 65520278
EXPLAIN select SUM(call_duration) as total_call_duration from xyz where target_id='1';
QUERY PLAN
----------
EXPRESSION: sum(call_duration::float)
NUMBER OF SHARDS: 21
NUMBER OF SERIES: 85134
CACHED VALUES: 0
NUMBER OF FILES: 24642
NUMBER OF BLOCKS: 31608
SIZE OF BLOCKS: 65520278
EXPLAIN select Count(Distinct(recipient_id)) as total_recipients from xyz where target_id='1';
QUERY PLAN
----------
EXPRESSION: recipient_id::integer
NUMBER OF SHARDS: 21
NUMBER OF SERIES: 85134
CACHED VALUES: 0
NUMBER OF FILES: 24642
NUMBER OF BLOCKS: 31608
SIZE OF BLOCKS: 82448255

How can I efficiently transform a two-column range into an expanded table?

I'm trying to use geo IP data in snowflake. This involves several things:
1) A source table with a CIDR IP range and a geoname_ID and its lat/long coords
2) I've used the parse_ip function and extracted the range_start and range_end values as simple integer columns in the ipv4 0-4.2bn range. Some ranges consist of 1 IP, some may have as many as 16.7 million.
So, the 3.1 million rows in the intermediary table data look something like this :
RANGE_START RANGE_END GEONAME_ID LATITUDE LONGITUDE
214690946 214690946 4556793 39.84980011 -75.37470245
214690947 214690947 6252001 37.75099945 -97.82199860
214690948 214690951 6252001 37.75099945 -97.82199860
214690952 214690959 6252001 37.75099945 -97.82199860
214690960 214690975 6252001 37.75099945 -97.82199860
As you can see, a geoname ID can have multiple ranges associated with it.
The problem is joining a (parsed into an integer value) IP with this table requires non-equality joins, which are painfully slow in snowflake at the moment (about 1000x slower empirically). So I would like to expand the table above into having one row per IP in range, i.e the last row with the range 214690960 to 214690975 would turn into 16 rows, while preserving geoname and lat long for each of the new rows. The only way I could think to do this was by doing a non-equi join to a generator table, but this took 30 minutes on a 3xl for 1000 rows, generating about 1.2m result rows. I have 3.1 million rows in this range to flatten, so that won't work.
Any ideas, anyone?
Here is what I tried so far:
create OR REPLACE table GENERATOR_TABLE (IP INT);
INSERT INTO GENERATOR_TABLE SELECT ROW_NUMBER() over (ORDER BY NULL) AS IP FROM TABLE(GENERATOR(ROWCOUNT => 4228250627)) ORDER BY IP;
create or replace table GEO_INTERMEDIARY as
(select network_parsed:ipv4_range_start::number as range_start, network_parsed:"ipv4_range_end"::number range_end, geoname_id, latitude, longitude from GEO_SOURCE order by range_start, range_end);
CREATE OR REPLACE TABLE EXPANDED_GEO AS
select * from (select * from GEO_INTERMEDIARY order by geoname_id limit 1000 offset 0) A
JOIN GENERATOR_TABLE B ON B.IP >= A.RANGE_START AND B.IP <= A.RANGE_END
ORDER BY IP;
For such pattern you could indeed try using generator, but I usually end up using JavaScript UDTFs.
Here's an example function and usage on your data:
create or replace table x(
RANGE_START int,
RANGE_END int,
GEONAME_ID int,
LATITUDE double,
LONGITUDE double
) as
select * from values
(214690946,214690946,4556793,39.84980011,-75.37470245),
(214690947,214690947,6252001,37.75099945,-97.82199860),
(214690948,214690951,6252001,37.75099945,-97.82199860);
create or replace function magic(
range_start double,
range_end double,
geoname_id double,
latitude double,
longitude double
)
returns table (
ip double,
geoname_id double,
latitude double,
longitude double
) language javascript as
$$
{
processRow: function(row, rowWriter, context) {
let start = row.RANGE_START
let end = row.RANGE_END
while (start <= end) {
rowWriter.writeRow({
IP: start,
GEONAME_ID: row.GEONAME_ID,
LATITUDE: row.LATITUDE,
LONGITUDE: row.LONGITUDE,
});
start++;
}
}
}
$$;
select m.* from x,
table(magic(range_start::double, range_end::double,
geoname_id::double, latitude, longitude)) m;
-----------+------------+-------------+--------------+
IP | GEONAME_ID | LATITUDE | LONGITUDE |
-----------+------------+-------------+--------------+
214690946 | 4556793 | 39.84980011 | -75.37470245 |
214690947 | 6252001 | 37.75099945 | -97.8219986 |
214690948 | 6252001 | 37.75099945 | -97.8219986 |
214690949 | 6252001 | 37.75099945 | -97.8219986 |
214690950 | 6252001 | 37.75099945 | -97.8219986 |
214690951 | 6252001 | 37.75099945 | -97.8219986 |
-----------+------------+-------------+--------------+
The only gotcha here is that JS only supports double types, but for this data, it's ok, you will not see any precision loss.
I tested it on 1M ranges producing 10M IPs, it finished in seconds.

how to group a date column based on date range in oracle

I have a table which contains a feedback about a product.It has feedback type (positive ,negative) which is a text column, date on which comments made. I need to get total count of positive ,negative feedback for particular time period . For example if the date range is 30 days, I need to get total count of positive ,negative feedback for 4 weeks , if the date range is 6 months , I need to get total count of positive ,negative feedback for each month. How to group the count based on date.
+------+------+----------+----------+---------------+--+--+--+
| Slno | User | Comments | type | commenteddate | | | |
+------+------+----------+----------+---------------+--+--+--+
| 1 | a | aaaa | positive | 22-jun-2016 | | | |
| 2 | b | bbb | positive | 1-jun-2016 | | | |
| 3 | c | qqq | negative | 2-jun-2016 | | | |
| 4 | d | ccc | neutral | 3-may-2016 | | | |
| 5 | e | www | positive | 2-apr-2016 | | | |
| 6 | f | s | negative | 11-nov-2015 | | | |
+------+------+----------+----------+---------------+--+--+--+
Query i tried is
SELECT type, to_char(commenteddate,'DD-MM-YYYY'), Count(type) FROM comments GROUP BY type, to_char(commenteddate,'DD-MM-YYYY');
Here's a kick at the can...
Assumptions:
you want to be able to switch the groupings to weekly or monthly only
the start of the first period will be the first date in the feedback data; intervals will be calculated from this initial date
output will show feedback value, time period, count
time periods will not overlap so periods will be x -> x + interval - 1 day
time of day is not important (time for commented dates is always 00:00:00)
First, create some sample data (100 rows):
drop table product_feedback purge;
create table product_feedback
as
select rownum as slno
, chr(65 + MOD(rownum, 26)) as userid
, lpad(chr(65 + MOD(rownum, 26)), 5, chr(65 + MOD(rownum, 26))) as comments
, trunc(sysdate) + rownum + trunc(dbms_random.value * 10) as commented_date
, case mod(rownum * TRUNC(dbms_random.value * 10), 3)
when 0 then 'positive'
when 1 then 'negative'
when 2 then 'neutral' end as feedback
from dual
connect by level <= 100
;
Here's what my sample data looks like:
select *
from product_feedback
;
SLNO USERID COMMENTS COMMENTED_DATE FEEDBACK
1 B BBBBB 2016-08-06 neutral
2 C CCCCC 2016-08-06 negative
3 D DDDDD 2016-08-14 positive
4 E EEEEE 2016-08-16 negative
5 F FFFFF 2016-08-09 negative
6 G GGGGG 2016-08-14 positive
7 H HHHHH 2016-08-17 positive
8 I IIIII 2016-08-18 positive
9 J JJJJJ 2016-08-12 positive
10 K KKKKK 2016-08-15 neutral
11 L LLLLL 2016-08-23 neutral
12 M MMMMM 2016-08-19 positive
13 N NNNNN 2016-08-16 neutral
...
Now for the fun part. Here's the gist:
find out what the earliest and latest commented dates are in the data
include a query where you can set the time period (to "WEEKS" or "MONTHS")
generate all of the (weekly or monthly) time periods between the min/max dates
join the product feedback to the time periods (commented date between start and end) with an outer join in case you want to see all time periods whether or not there was any feedback
group the joined result by feedback, period start, and period end, and set up a column to count one of the 3 possible feedback values
x
with
min_max_dates -- get earliest and latest feedback dates
as
(select min(commented_date) min_date, max(commented_date) max_date
from product_feedback
)
, time_period_interval
as
(select 'MONTHS' as tp_interval -- set the interval/time period here
from dual
)
, -- generate all time periods between the start date and end date
time_periods (start_of_period, end_of_period, max_date, time_period) -- recursive with clause - fun stuff!
as
(select mmd.min_date as start_of_period
, CASE WHEN tpi.tp_interval = 'WEEKS'
THEN mmd.min_date + 7
WHEN tpi.tp_interval = 'MONTHS'
THEN ADD_MONTHS(mmd.min_date, 1)
ELSE NULL
END - 1 as end_of_period
, mmd.max_date
, tpi.tp_interval as time_period
from time_period_interval tpi
cross join
min_max_dates mmd
UNION ALL
select CASE WHEN time_period = 'WEEKS'
THEN start_of_period + 7 * (ROWNUM )
WHEN time_period = 'MONTHS'
THEN ADD_MONTHS(start_of_period, ROWNUM)
ELSE NULL
END as start_of_period
, CASE WHEN time_period = 'WEEKS'
THEN start_of_period + 7 * (ROWNUM + 1)
WHEN time_period = 'MONTHS'
THEN ADD_MONTHS(start_of_period, ROWNUM + 1)
ELSE NULL
END - 1 as end_of_period
, max_date
, time_period
from time_periods
where end_of_period <= max_date
)
-- now put it all together
select pf.feedback
, tp.start_of_period
, tp.end_of_period
, count(*) as feedback_count
from time_periods tp
left outer join
product_feedback pf
on pf.commented_date between tp.start_of_period and tp.end_of_period
group by tp.start_of_period
, tp.end_of_period
, pf.feedback
order by pf.feedback
, tp.start_of_period
;
Output:
negative 2016-08-06 2016-09-05 6
negative 2016-09-06 2016-10-05 7
negative 2016-10-06 2016-11-05 8
negative 2016-11-06 2016-12-05 1
neutral 2016-08-06 2016-09-05 6
neutral 2016-09-06 2016-10-05 5
neutral 2016-10-06 2016-11-05 11
neutral 2016-11-06 2016-12-05 2
positive 2016-08-06 2016-09-05 17
positive 2016-09-06 2016-10-05 16
positive 2016-10-06 2016-11-05 15
positive 2016-11-06 2016-12-05 6
-- EDIT --
New and improved, all in one easy to use procedure. (I will assume you can configure the procedure to make use of the query in whatever way you need.) I made some changes to simplify the CASE statements in a few places and note that for whatever reason using a LEFT OUTER JOIN in the main SELECT results in an ORA-600 error for me so I switched it to INNER JOIN.
CREATE OR REPLACE PROCEDURE feedback_counts(p_days_chosen IN NUMBER, p_cursor OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_cursor FOR
with
min_max_dates -- get earliest and latest feedback dates
as
(select min(commented_date) min_date, max(commented_date) max_date
from product_feedback
)
, time_period_interval
as
(select CASE
WHEN p_days_chosen BETWEEN 1 AND 10 THEN 'DAYS'
WHEN p_days_chosen > 10 AND p_days_chosen <=31 THEN 'WEEKS'
WHEN p_days_chosen > 31 AND p_days_chosen <= 365 THEN 'MONTHS'
ELSE '3-MONTHS'
END as tp_interval -- set the interval/time period here
from dual --(SELECT p_days_chosen as days_chosen from dual)
)
, -- generate all time periods between the start date and end date
time_periods (start_of_period, end_of_period, max_date, tp_interval) -- recursive with clause - fun stuff!
as
(select mmd.min_date as start_of_period
, CASE tpi.tp_interval
WHEN 'DAYS'
THEN mmd.min_date + 1
WHEN 'WEEKS'
THEN mmd.min_date + 7
WHEN 'MONTHS'
THEN mmd.min_date + 30
WHEN '3-MONTHS'
THEN mmd.min_date + 90
ELSE NULL
END - 1 as end_of_period
, mmd.max_date
, tpi.tp_interval
from time_period_interval tpi
cross join
min_max_dates mmd
UNION ALL
select CASE tp_interval
WHEN 'DAYS'
THEN start_of_period + 1 * ROWNUM
WHEN 'WEEKS'
THEN start_of_period + 7 * ROWNUM
WHEN 'MONTHS'
THEN start_of_period + 30 * ROWNUM
WHEN '3-MONTHS'
THEN start_of_period + 90 * ROWNUM
ELSE NULL
END as start_of_period
, start_of_period
+ CASE tp_interval
WHEN 'DAYS'
THEN 1
WHEN 'WEEKS'
THEN 7
WHEN 'MONTHS'
THEN 30
WHEN '3-MONTHS'
THEN 90
ELSE NULL
END * (ROWNUM + 1)
- 1 as end_of_period
, max_date
, tp_interval
from time_periods
where end_of_period <= max_date
)
-- now put it all together
select pf.feedback
, tp.start_of_period
, tp.end_of_period
, count(*) as feedback_count
from time_periods tp
inner join -- currently a bug that prevents the procedure from compiling with a LEFT OUTER JOIN
product_feedback pf
on pf.commented_date between tp.start_of_period and tp.end_of_period
group by tp.start_of_period
, tp.end_of_period
, pf.feedback
order by tp.start_of_period
, pf.feedback
;
END;
Test the procedure (in something like SQLPlus or SQL Developer):
var x refcursor
exec feedback_counts(10, :x)
print :x

IBM DB2 SQLCODE -1424, SQLSTATE 54040 when trying to create a trigger

I have tried to create the following trigger (DB2/LINUXX8664 9.7.2 running over Ubuntu 10.04.2 LTS) but I always get this:
Error report:
DB2 SQL error: SQLCODE: -1424, SQLSTATE: 54040, SQLERRMC: 2
According IBM DB2 documentation:
Too many references to transition variables and transition table columns or the row length for these references is too long. Reason code=rc.
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.messages.sql.doc/doc/msql01424n.html
I really do not understand that explanation. Here the stored procedure and trigger:
CREATE PROCEDURE SP_INSERT_UPDATE_REPNUM (
IN RECNUM INTEGER,
IN CUSTOMER_ID INTEGER,
IN Q_CODE VARCHAR(14),
IN S_CODE VARCHAR(14),
IN REP_STATUS INTEGER,
IN P_CODE INTEGER,
IN REPNUMRG_ID INTEGER,
IN VOLG_LET VARCHAR(1),
IN REP_DATUM DATE,
IN REP_INI VARCHAR(2),
IN INGEBOEKT_DATUM DATE,
IN INGEBOEKT_INI VARCHAR(2),
IN WIJZIGING_DATUM DATE,
IN WIJZIGING_INI VARCHAR(2),
IN OMSCR_STORING VARCHAR(5),
IN OMSCR_WERKZ VARCHAR(5),
IN OMSCR_OPMERKING VARCHAR(5),
IN OMSCR_GEBREK VARCHAR(5),
IN OMSCR_MAT VARCHAR(5),
IN REP_TIJD FLOAT,
IN REP_GEDAAN CHAR(1),
IN ACTION CHAR(1)
)
SPECIFIC SP_INSERT_UPDATE_REPNUM
DYNAMIC RESULT SETS 0
DETERMINISTIC
LANGUAGE JAVA
PARAMETER STYLE JAVA
NO DBINFO
NOT FENCED
THREADSAFE
MODIFIES SQL DATA
PROGRAM TYPE SUB
EXTERNAL NAME 'RepairMigration!insertServiceReport'
and here the trigger:
CREATE TRIGGER INSERT_REPNUM
AFTER INSERT ON REPNUM
REFERENCING NEW ROW AS NROW
FOR EACH ROW MODE DB2SQL
BEGIN
CALL SP_INSERT_UPDATE_REPNUM(
NROW.RECNUM,
NROW.CUSTOMER_ID,
NROW.Q_CODE,
NROW.S_CODE,
NROW.REP_STATUS,
NROW.P_CODE,
NROW.REPNUMRG_ID,
NROW.VOLG_LET,
NROW.REP_DATUM,
NROW.REP_INI,
NROW.INGEBOEKT_DATUM,
NROW.INGEBOEKT_INI,
NROW.WIJZIGING_DATUM,
NROW.WIJZIGING_INI,
NROW.OMSCR_STORING,
NROW.OMSCR_WERKZ,
NROW.OMSCR_OPMERKING,
NROW.OMSCR_GEBREK,
NROW.OMSCR_MAT,
NROW.REP_TIJD,
NROW.REP_GEDAAN,
'I'
);
END
the table structure is thsi one:
RECNUM INTEGER 4 0 N
Q_CODE CHARACTER 14 0 N ''
U_Q_CODE CHARACTER 14 0 N
S_CODE CHARACTER 14 0 N ''
U_S_CODE CHARACTER 14 0 N
VOLG_LET CHARACTER 1 0 N ''
U_VOLG_LET CHARACTER 1 0 N
REP_DATUM DATE 4 0 N '0001-01-01'
REP_INI CHARACTER 2 0 N ''
P_CODE INTEGER 4 0 N 0
CUSTOMER_ID INTEGER 4 0 N 0
REPNUMHD_ID INTEGER 4 0 N 0
REPNUMRG_ID INTEGER 4 0 N 0
REP_STATUS SMALLINT 2 0 N 0
KONTAKT_PER CHARACTER 25 0 N ''
KONTAKT_TEL CHARACTER 20 0 N ''
OMSCR_STORING VARCHAR 512 0 N ''
OMSCR_WERKZ VARCHAR 2000 0 N ''
OMSCR_MAT VARCHAR 512 0 N ''
WIJZIGING_DATUM DATE 4 0 N '0001-01-01'
WIJZIGING_INI CHARACTER 2 0 N ''
INGEBOEKT_DATUM DATE 4 0 N '0001-01-01'
INGEBOEKT_INI CHARACTER 2 0 N ''
REP_GEDAAN CHARACTER 1 0 N ''
U_REP_GEDAAN CHARACTER 1 0 N
STATUS SMALLINT 2 0 N 0
UW_OPDRACHT CHARACTER 20 0 N ''
REP_UREN SMALLINT 2 0 N 0
REP_MINUTEN SMALLINT 2 0 N 0
OMSCR_OPMERKING VARCHAR 1008 0 N ''
OMSCR_GEBREK VARCHAR 512 0 N ''
SERVICE_NUMMER INTEGER 4 0 N 0
PRIJS_OPGAVE CHARACTER 1 0 N ''
CURRENCY SMALLINT 2 0 N 0
REP_TIJD INTEGER 4 0 N 0
After trying to execute the trigger, I get the error. How can I solve this?
UPDATE
It looks that I need to create a temporary tablespace. Listing all my tablespaces, I got some with more than 4k, for example this one:
Tablespace ID = 7
Name = TEMPSPACE1234
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
Total pages = 1024
Useable pages = 1008
Used pages = 432
Free pages = 576
High water mark (pages) = 528
Page size (bytes) = 32768
Extent size (pages) = 16
Prefetch size (pages) = 16
Number of containers = 1
1) Create a 32K Buffer Pool
Example:
CREATE BUFFERPOOL "BUFFERPOOLLARGE" IMMEDIATE
ALL DBPARTITIONNUMS SIZE AUTOMATIC
NUMBLOCKPAGES 0
PAGESIZE 32 K;
2) Create a 32K SYSTEM TEMPORARY TABLESPACE
Example:
CREATE SYSTEM TEMPORARY TABLESPACE "TEMPSPACELARGE"
IN DATABASE PARTITION GROUP "IBMTEMPGROUP"
PAGESIZE 32 K
MANAGED BY AUTOMATIC STORAGE
EXTENTSIZE 32
BUFFERPOOL "BUFFERPOOLLARGE"
OVERHEAD INHERIT
TRANSFERRATE INHERIT
USING STOGROUP "IBMSTOGROUP"
FILE SYSTEM CACHING;
3) Run CREATE PROCEDURE Script Again.
OBS:In the examples I used DB2 automatic TABLESPACE.

How to get sum of values in grid?

For example I have grid.
//grid for answers_for_online
var answersGridForOnline5 = new Ext.grid.GridPanel({
id : 'grid_for_stats',
store : storez3,
columns : answers_columns5,
});
my column:
var answers_columns5 = [{
id: "idz",
header: 'idz',
dataIndex: "idz",
renderer: fun_f
}];
and renderer function
function fun(n, j, k, m, h, i) {
var count = store.snapshot ? store.snapshot.length : store.getCount()
var cez = k.get("scale")
var ce = ( 2 / count ) * 100
return ce + " % "
}
Question: In database I have for example: scales (that user answered on scale-question)
id | scale
1 | 4
2 | 4
3 | 1
4 | 2
How i can sum scales (and group them of course) and put this in my grid?
For example in my grid i should get:
scale | scale %
1 | 25%
2 | 25%
4 | 50%
I advise you don't attempt to do it inside Grid/Store. Instead process the data before loading it to store - for example do it in database with GROUP BY statement.
To get the sum of values in a store, you can use Store.sum()

Resources