Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-25-2008, 01:50 PM
Jaap W. van Dijk
 
Posts: n/a
Default Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

Hi,

I'm on Oracle 9.2.0.5, Open VMS.

I perform an

INSERT INTO target
SELECT * FROM source

If I do this noparallel, the result from the select is immediately
inserted into the target.

If I do this in parallel, the result of the selects from a slave set
are first buffered in TEMP. After this is done, a slave set starts to
insert the contents from the buffers into the target.

Why this timeconsuming buffering? Can anything be done?

While I am writing this, I wonder: I let Oracle decide which degree of
parallellization to use. Maybe buffering only takes places if the
degree differs between SELECT and INSERT? (I should test myself, but
don't have the opportunity right now).

Regards, Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-25-2008, 01:50 PM
sybrandb
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?



On Nov 22, 11:23 am, j.w.vandijk.removet...@hetnet.nl (Jaap W. van
Dijk) wrote:
> Hi,
>
> I'm on Oracle 9.2.0.5, Open VMS.
>
> I perform an
>
> INSERT INTO target
> SELECT * FROM source
>
> If I do this noparallel, the result from the select is immediately
> inserted into the target.
>
> If I do this in parallel, the result of the selects from a slave set
> are first buffered in TEMP. After this is done, a slave set starts to
> insert the contents from the buffers into the target.
>
> Why this timeconsuming buffering? Can anything be done?
>
> While I am writing this, I wonder: I let Oracle decide which degree of
> parallellization to use. Maybe buffering only takes places if the
> degree differs between SELECT and INSERT? (I should test myself, but
> don't have the opportunity right now).
>
> Regards, Jaap.


IMHO parallelization is pretty useless if the affected tables aren't
striped over several disks.
I remember Tom Kyte stating somewhere you should use parallelization
only if you can't get rid of full table scans at all.
Also parallelization always will use parallel server slaves and a query
coordinator (the original session), so I bet this is what you are
looking at right now: data is retrieved by slaves and inserted by the
coordinator.
And yes, this is a 'feature', while you seem to qualify it as a bug.

--
Sybrand Bakker
Senior Oracle DBA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 01:50 PM
R. Schierbeek
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

Jaap W. van Dijk <j.w.vandijk.removethis@hetnet.nl> schreef in bericht
> Hi,
> I'm on Oracle 9.2.0.5, Open VMS.
>
> I perform an
> INSERT INTO target
> SELECT * FROM source
>
> If I do this noparallel, the result from the select is immediately inserted into the target.
>
> If I do this in parallel, the result of the selects from a slave set
> are first buffered in TEMP. After this is done, a slave set starts to
> insert the contents from the buffers into the target.
>
> Why this timeconsuming buffering? Can anything be done?
>
> While I am writing this, I wonder: I let Oracle decide which degree of
> parallellization to use. Maybe buffering only takes places if the
> degree differs between SELECT and INSERT? (I should test myself, but
> don't have the opportunity right now).
> Regards, Jaap.


Well Jaap,
If you insert less then 100.000 rows a parallel insert might not be faster then
a normal insert /*+APPEND */. Check out the APPEND hint.

If you still want to do the parallel insert without TEMP usage then
drop the indexes on the target table. Oracle first inserts the table data;
then does some sorting on the new index data and rebuilds them.
No index > no sorts needed.

Cheers,
Roelof Schierbeek; DBA


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 01:50 PM
Jaap W. van Dijk
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

On 22 Nov 2006 03:54:40 -0800, "sybrandb" <sybrandb@gmail.com> wrote:

>
>
>On Nov 22, 11:23 am, j.w.vandijk.removet...@hetnet.nl (Jaap W. van
>Dijk) wrote:
>> Hi,
>>
>> I'm on Oracle 9.2.0.5, Open VMS.
>>
>> I perform an
>>
>> INSERT INTO target
>> SELECT * FROM source
>>
>> If I do this noparallel, the result from the select is immediately
>> inserted into the target.
>>
>> If I do this in parallel, the result of the selects from a slave set
>> are first buffered in TEMP. After this is done, a slave set starts to
>> insert the contents from the buffers into the target.
>>
>> Why this timeconsuming buffering? Can anything be done?
>>
>> While I am writing this, I wonder: I let Oracle decide which degree of
>> parallellization to use. Maybe buffering only takes places if the
>> degree differs between SELECT and INSERT? (I should test myself, but
>> don't have the opportunity right now).
>>
>> Regards, Jaap.

>
>IMHO parallelization is pretty useless if the affected tables aren't
>striped over several disks.
>I remember Tom Kyte stating somewhere you should use parallelization
>only if you can't get rid of full table scans at all.
>Also parallelization always will use parallel server slaves and a query
>coordinator (the original session), so I bet this is what you are
>looking at right now: data is retrieved by slaves and inserted by the
>coordinator.
>And yes, this is a 'feature', while you seem to qualify it as a bug.
>
>--
>Sybrand Bakker
>Senior Oracle DBA
>


Maybe the coordinator wants to coordinate between select and insert ,
but it doesn't insert the records itself: that is also done by a slave
set.

I took a look at the Concept Manual. There inter-operation
parallellism is discussed, where data flows directly from one slave
set to the next (fig 18-3 on page 18-7). What is pictured there - two
slave sets doing a select and a sort - could IMO as easily have been
two slave sets doing a select and an insert, without any buffering. As
I said before: maybe the optimizer needs to know beforehand that the
degree of select and insert is the same, so when I have the
opportunity, I perform a test.

Regarding the parallel gain: selecting also takes an amount of CPU,
and parallellizing that improves the select noticably, even if
everything is read from the same disk, especially if the select is
part of the transformation step of the load of a datawarehouse, with
lots of complex case statements in the select list, consuming lots of
CPU.

Regards, Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-25-2008, 01:51 PM
EscVector
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?


Jaap W. van Dijk wrote:
> Hi,
>
> I'm on Oracle 9.2.0.5, Open VMS.
>
> I perform an
>
> INSERT INTO target
> SELECT * FROM source
>
> If I do this noparallel, the result from the select is immediately
> inserted into the target.
>
> If I do this in parallel, the result of the selects from a slave set
> are first buffered in TEMP. After this is done, a slave set starts to
> insert the contents from the buffers into the target.
>
> Why this timeconsuming buffering? Can anything be done?
>
> While I am writing this, I wonder: I let Oracle decide which degree of
> parallellization to use. Maybe buffering only takes places if the
> degree differs between SELECT and INSERT? (I should test myself, but
> don't have the opportunity right now).
>
> Regards, Jaap.


The second time around is always faster if you've run the query and not
flushed sga. Parallel always reads from disk. No parallel uses buffer
cache. Parallel needs to sort hence the temp. Johnathan Lewis
Cost-based Oracle has some good info on this. I like tkyes stuff too,
but sometimes Kytes stuff is not as Warehouse as I like. Parallel is
great if data is huge and the entire machine can be devoted to a single
session. Otherwise, it can cause pain. Why is it an issue if you can
do it fast w/o parallel?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-25-2008, 01:51 PM
EscVector
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?


R. Schierbeek wrote:
> Jaap W. van Dijk <j.w.vandijk.removethis@hetnet.nl> schreef in bericht
> > Hi,
> > I'm on Oracle 9.2.0.5, Open VMS.
> >
> > I perform an
> > INSERT INTO target
> > SELECT * FROM source
> >
> > If I do this noparallel, the result from the select is immediately inserted into the target.
> >
> > If I do this in parallel, the result of the selects from a slave set
> > are first buffered in TEMP. After this is done, a slave set starts to
> > insert the contents from the buffers into the target.
> >
> > Why this timeconsuming buffering? Can anything be done?
> >
> > While I am writing this, I wonder: I let Oracle decide which degree of
> > parallellization to use. Maybe buffering only takes places if the
> > degree differs between SELECT and INSERT? (I should test myself, but
> > don't have the opportunity right now).
> > Regards, Jaap.

>
> Well Jaap,
> If you insert less then 100.000 rows a parallel insert might not be faster then
> a normal insert /*+APPEND */. Check out the APPEND hint.
>
> If you still want to do the parallel insert without TEMP usage then
> drop the indexes on the target table. Oracle first inserts the table data;
> then does some sorting on the new index data and rebuilds them.
> No index > no sorts needed.
>
> Cheers,
> Roelof Schierbeek; DBAb


So if I offline my tempspace and run a parallel query it will work as
long as the table being queried has not indexes?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-25-2008, 01:51 PM
EscVector
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?


EscVector wrote:
> R. Schierbeek wrote:
> > Jaap W. van Dijk <j.w.vandijk.removethis@hetnet.nl> schreef in bericht
> > > Hi,
> > > I'm on Oracle 9.2.0.5, Open VMS.
> > >
> > > I perform an
> > > INSERT INTO target
> > > SELECT * FROM source
> > >
> > > If I do this noparallel, the result from the select is immediately inserted into the target.
> > >
> > > If I do this in parallel, the result of the selects from a slave set
> > > are first buffered in TEMP. After this is done, a slave set starts to
> > > insert the contents from the buffers into the target.
> > >
> > > Why this timeconsuming buffering? Can anything be done?
> > >
> > > While I am writing this, I wonder: I let Oracle decide which degree of
> > > parallellization to use. Maybe buffering only takes places if the
> > > degree differs between SELECT and INSERT? (I should test myself, but
> > > don't have the opportunity right now).
> > > Regards, Jaap.

> >
> > Well Jaap,
> > If you insert less then 100.000 rows a parallel insert might not be faster then
> > a normal insert /*+APPEND */. Check out the APPEND hint.
> >
> > If you still want to do the parallel insert without TEMP usage then
> > drop the indexes on the target table. Oracle first inserts the table data;
> > then does some sorting on the new index data and rebuilds them.
> > No index > no sorts needed.
> >
> > Cheers,
> > Roelof Schierbeek; DBAb

>
> So if I offline my tempspace and run a parallel query it will work as
> long as the table being queried has not indexes?


Offline by meaning I kill the temp file to make sure it can't be used...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-25-2008, 01:51 PM
R. Schierbeek
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

"EscVector" <Junk@webthere.com> wrote
> R. Schierbeek wrote:
>> Jaap W. van Dijk <j.w.vandijk.removethis@hetnet.nl> schreef in bericht
>> > Hi,
>> > I'm on Oracle 9.2.0.5, Open VMS.
>> > I perform an
>> > INSERT INTO target SELECT * FROM source
>> >
>> > If I do this noparallel, the result from the select is immediately inserted into the target.
>> >
>> > If I do this in parallel, the result of the selects from a slave set
>> > are first buffered in TEMP. After this is done, a slave set starts to
>> > insert the contents from the buffers into the target.
>> >
>> > Why this timeconsuming buffering? Can anything be done?
>> >
>> > While I am writing this, I wonder: I let Oracle decide which degree of
>> > parallellization to use. Maybe buffering only takes places if the
>> > degree differs between SELECT and INSERT? (I should test myself, but
>> > don't have the opportunity right now).
>> > Regards, Jaap.

>>
>> Well Jaap,
>> If you insert less then 100.000 rows a parallel insert might not be faster then
>> a normal insert /*+APPEND */. Check out the APPEND hint.
>>
>> If you still want to do the parallel insert without TEMP usage then
>> drop the indexes on the target table. Oracle first inserts the table data;
>> then does some sorting on the new index data and rebuilds them.
>> No index > no sorts needed.
>>
>> Cheers,
>> Roelof Schierbeek; DBAb

>
> So if I offline my tempspace and run a parallel query it will work as
> long as the table being queried has not indexes?


Yes it will work as long as the table being inserted into has not indexes.
If you have indexes - well go ahead and make my day !

And take a look at temp/sort table while u're inserting, eg v$sort_usage or v$sort_segment:
col current_users for 999 head 'curr|users'

col FREED_EXTENTS for 999 head 'FREED|EXTENTS'

col MAX_USED_SIZE head 'MAX_USED|SIZE'

select current_users,total_extents
, (USED_BLOCKS * &&block_size)/1024 used_temp
, (MAX_USED_BLOCKS *&&block_size)/1024 max_used
,freed_extents, extent_hits
,max_size, max_used_size
from v$sort_segment
Cheers
Roelof Schierbeek; DBA




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-25-2008, 01:51 PM
Jaap W. van Dijk
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

On 22 Nov 2006 07:03:39 -0800, "EscVector" <Junk@webthere.com> wrote:

>
>Jaap W. van Dijk wrote:
>> Hi,
>>
>> I'm on Oracle 9.2.0.5, Open VMS.
>>
>> I perform an
>>
>> INSERT INTO target
>> SELECT * FROM source
>>
>> If I do this noparallel, the result from the select is immediately
>> inserted into the target.
>>
>> If I do this in parallel, the result of the selects from a slave set
>> are first buffered in TEMP. After this is done, a slave set starts to
>> insert the contents from the buffers into the target.
>>
>> Why this timeconsuming buffering? Can anything be done?
>>
>> While I am writing this, I wonder: I let Oracle decide which degree of
>> parallellization to use. Maybe buffering only takes places if the
>> degree differs between SELECT and INSERT? (I should test myself, but
>> don't have the opportunity right now).
>>
>> Regards, Jaap.

>
>The second time around is always faster if you've run the query and not
>flushed sga. Parallel always reads from disk. No parallel uses buffer
>cache. Parallel needs to sort hence the temp. Johnathan Lewis
>Cost-based Oracle has some good info on this. I like tkyes stuff too,
>but sometimes Kytes stuff is not as Warehouse as I like. Parallel is
>great if data is huge and the entire machine can be devoted to a single
>session. Otherwise, it can cause pain. Why is it an issue if you can
>do it fast w/o parallel?
>


Because it needs to be faster.

noparallel ==> slow select , slow insert, no buffering

parallel ==> fast select, fast insert, but buffering.
The fast select and insert more than outweigh the buffering, so this
is faster than noparallel.

But it would be really fast if I could do the select and insert
parallel without the buffering.

Regards, Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-25-2008, 01:54 PM
Jaap W. van Dijk
 
Posts: n/a
Default Re: Why does Oracle buffer the result from the select for a parallel INSERT INTO SELECT FROM?

On Wed, 22 Nov 2006 14:14:00 GMT, j.w.vandijk.removethis@hetnet.nl
(Jaap W. van Dijk) wrote:

>On 22 Nov 2006 03:54:40 -0800, "sybrandb" <sybrandb@gmail.com> wrote:
>
>>
>>
>>On Nov 22, 11:23 am, j.w.vandijk.removet...@hetnet.nl (Jaap W. van
>>Dijk) wrote:
>>> Hi,
>>>
>>> I'm on Oracle 9.2.0.5, Open VMS.
>>>
>>> I perform an
>>>
>>> INSERT INTO target
>>> SELECT * FROM source
>>>
>>> If I do this noparallel, the result from the select is immediately
>>> inserted into the target.
>>>
>>> If I do this in parallel, the result of the selects from a slave set
>>> are first buffered in TEMP. After this is done, a slave set starts to
>>> insert the contents from the buffers into the target.
>>>
>>> Why this timeconsuming buffering? Can anything be done?
>>>
>>> While I am writing this, I wonder: I let Oracle decide which degree of
>>> parallellization to use. Maybe buffering only takes places if the
>>> degree differs between SELECT and INSERT? (I should test myself, but
>>> don't have the opportunity right now).
>>>
>>> Regards, Jaap.

>>
>>IMHO parallelization is pretty useless if the affected tables aren't
>>striped over several disks.
>>I remember Tom Kyte stating somewhere you should use parallelization
>>only if you can't get rid of full table scans at all.
>>Also parallelization always will use parallel server slaves and a query
>>coordinator (the original session), so I bet this is what you are
>>looking at right now: data is retrieved by slaves and inserted by the
>>coordinator.
>>And yes, this is a 'feature', while you seem to qualify it as a bug.
>>
>>--
>>Sybrand Bakker
>>Senior Oracle DBA
>>

>
>Maybe the coordinator wants to coordinate between select and insert ,
>but it doesn't insert the records itself: that is also done by a slave
>set.
>
>I took a look at the Concept Manual. There inter-operation
>parallellism is discussed, where data flows directly from one slave
>set to the next (fig 18-3 on page 18-7). What is pictured there - two
>slave sets doing a select and a sort - could IMO as easily have been
>two slave sets doing a select and an insert, without any buffering. As
>I said before: maybe the optimizer needs to know beforehand that the
>degree of select and insert is the same, so when I have the
>opportunity, I perform a test.
>
>Regarding the parallel gain: selecting also takes an amount of CPU,
>and parallellizing that improves the select noticably, even if
>everything is read from the same disk, especially if the select is
>part of the transformation step of the load of a datawarehouse, with
>lots of complex case statements in the select list, consuming lots of
>CPU.
>
>Regards, Jaap.


After some more reading and thinking: I thought that data got PIPED
through the slave set processes, so the second slave set consumes
immediately what the first set produces. This certainly is what figure
18-3 in the Concept manual is suggesting. But instead produce from the
first slave set is buffered in totality first, and then this is
processed by the second slave set. A similar difference as between the
ordinary table function and the pipelined table function.

I don't see any functional impossibilities, so I wonder why Oracle
didn't implement the pipelined version, which would be much faster.

Regards,

Jaap.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421