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 05-16-2008, 01:39 PM
Tom
 
Posts: n/a
Default Faster index creation

I need to create 2 indexes on a 107 GB table. The indexes have no
columns in common. I have a 8 Gig SGA.

I am not looking forward to 2 tablescans so I was thinking of running
both create index statements at the same time from different sqlplus
sessions and hoping that the data for the slower statement is in
cache for the faster statement.

Or as an alternative, I was thinking of first creating an index which
was a superset of the columns in the other 2 indexes and then creating
the other indexes. They will just use the first index instead of
doing table scans. When they are done, drop the first index.

I'm hoping that someone else has better ideas or that there is just a
simpler way.

.. . . Tom
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-16-2008, 01:39 PM
Mladen Gogala
 
Posts: n/a
Default Re: Faster index creation

On Wed, 14 May 2008 08:02:03 -0700, Tom wrote:

> I am not looking forward to 2 tablescans so I was thinking of running
> both create index statements at the same time from different sqlplus
> sessions and hoping that the data for the slower statement is in cache
> for the faster statement.
>
> Or as an alternative, I was thinking of first creating an index which
> was a superset of the columns in the other 2 indexes and then creating
> the other indexes. They will just use the first index instead of doing
> table scans. When they are done, drop the first index.
>
> I'm hoping that someone else has better ideas or that there is just a
> simpler way.
>
> . . . Tom


First of all, if you are to employ "parallel" option, there will be
no caching. You will have quite a few segment checkpoints, though.
My advice would be to clench your teeth and take the 2 scans like a
man. A DBA got to do what a DBA got to do. Increase PGA_AGGREGATE_TARGET,
create indexes with "nologging" and byte the bullet.




--
http://mgogala.freehostia.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-16-2008, 01:39 PM
joel garry
 
Posts: n/a
Default Re: Faster index creation

On May 14, 8:02*am, Tom <tzebli...@autooneins.com> wrote:
> I need to create 2 indexes on a 107 GB table. *The indexes have no
> columns in common. *I have a 8 Gig SGA.
>
> I am not looking forward to 2 tablescans so I was thinking of running
> both create index statements at the same time from different sqlplus
> sessions and hoping that *the data for the slower statement is in
> cache for the faster statement.


I think you might have lock issues doing this. See
http://richardfoote.wordpress.com/20...ch-ch-changes/

Remember, DDL is not transaction oriented, so issues commits before
and after it runs, and so has to rely on locking to make sense. Also,
full table scans put the blocks read on the tail end of the LRU list,
so they age out first (see memory use section of performance tuning
guide).

>
> Or as an alternative, I was thinking of first creating an index which
> was a superset of the columns in the other 2 indexes and then creating
> the other indexes. *They will just use the first index instead of
> doing table scans. *When they are done, drop the first index.


This sounds good, though the docs say it _may_ use the index to build
the others. I would expect it to, but... test.

>
> I'm hoping that someone else has better ideas or that there is just a
> simpler way.


Listen to Mladen.

jg
--
@home.com is bogus.
Half-a-doc: http://www.oracle.com/technology/sof...acle10g/htdocs
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-16-2008, 01:39 PM
Mark D Powell
 
Posts: n/a
Default Re: Faster index creation

On May 14, 11:27*am, Mladen Gogala <mgog...@yahoo.com> wrote:
> On Wed, 14 May 2008 08:02:03 -0700, Tom wrote:
> > I am not looking forward to 2 tablescans so I was thinking of running
> > both create index statements at the same time from different sqlplus
> > sessions and hoping that *the data for the slower statement is in cache
> > for the faster statement.

>
> > Or as an alternative, I was thinking of first creating an index which
> > was a superset of the columns in the other 2 indexes and then creating
> > the other indexes. *They will just use the first index instead of doing
> > table scans. *When they are done, drop the first index.

>
> > I'm hoping that someone else has better ideas or that there is just a
> > simpler way.

>
> > . . . Tom

>
> First of all, if you are to employ "parallel" option, there will be
> no caching. You will have quite a few segment checkpoints, though.
> My advice would be to clench your teeth and take the 2 scans like a
> man. A DBA got to do what a DBA got to do. Increase PGA_AGGREGATE_TARGET,
> create indexes with "nologging" and byte the bullet.
>
> --http://mgogala.freehostia.com


Do not forget that If you run two index creates on the same table at
one time you will need to have enough temporary tablespace allocated
to handle both index builds and the two tasks will compete for IO
capacity for both the reading of the table and the use of sort plus
potentially the index target tablespace.

I would set work area management policy to manual, set the largest
practical sort_area_size possible and just run one index build at a
time.

I do not have experience using the parallel parameter on the index
build but I would hesitate to let Oracle use its calculated value for
the reasons Mladen mentioned. I might try 2 or 4 depending on how
many cpu the server has and how many physical disks temp and the table
are spread over. Sometimes less is better.

HTH -- Mark D Powell --
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-16-2008, 01:39 PM
bdbafh
 
Posts: n/a
Default Re: Faster index creation

On May 14, 11:02 am, Tom <tzebli...@autooneins.com> wrote:
> I need to create 2 indexes on a 107 GB table. The indexes have no
> columns in common. I have a 8 Gig SGA.
>
> I am not looking forward to 2 tablescans so I was thinking of running
> both create index statements at the same time from different sqlplus
> sessions and hoping that the data for the slower statement is in
> cache for the faster statement.
>
> Or as an alternative, I was thinking of first creating an index which
> was a superset of the columns in the other 2 indexes and then creating
> the other indexes. They will just use the first index instead of
> doing table scans. When they are done, drop the first index.
>
> I'm hoping that someone else has better ideas or that there is just a
> simpler way.
>
> . . . Tom


Tom,

Is the table partitioned? (enterprise edition + partitioning option
required)
What degree of parallelism is set for the table? (if any)
What version of the Oracle database server software are you referring
to?
What is the maximum OS IO size that is supported? (e.g. 1 MB)
What is the db_file_multiblock_read_count set to? (e.g. 16)
Have you gathered system stats under workload? (check sys.aux_stats$)
This would enable cpu costing.
The db_block_size would also be of interest, as would the tablespace
block size if it differs from the db_block_size.
(assume that it is 8192 bytes, but being a DW it might be 16K)

Perhaps the limiting factor is that the dbfmbrc is only say 8, but
could be set to 128 and grab a full 1 MB of data in a single IO call
(show parameter db_file)
Perhaps the limiting factor is that the pga_area_size is smallish
causing a small sort_area_size to be used during index creation.

If you're looking to make table scan and sorting operations cheaper
(and go faster) you might consider the following:
alter session set workarea_size_policy='MANUAL';
alter session set db_file_multiblock_read_count=128;
alter session set sort_area_size=536870912;


Larger values for sort_area_size would likely be helpful.
You might be limited on available physical memory.

If other user sessions are working with blocks from the heap table,
the likelihood of obtaining a large number of blocks from an extent in
a single read decreases.
Although it seems that accessing the blocks of the table at the same
time would reduce the runtime of the 2 index creations due to having
more blocks of that segment in memory, its much more likely that it
would cause contention and cause the effective dbfmbrc to be reduced
and the overall runtime to increase.

Hopefully you have a good test environment in which to test for
yourself.

-bdbafh


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-16-2008, 01:39 PM
bdbafh
 
Posts: n/a
Default Re: Faster index creation

On May 14, 1:53 pm, bdbafh <bdb...@gmail.com> wrote:
> On May 14, 11:02 am, Tom <tzebli...@autooneins.com> wrote:
>
>
>
> > I need to create 2 indexes on a 107 GB table. The indexes have no
> > columns in common. I have a 8 Gig SGA.

>
> > I am not looking forward to 2 tablescans so I was thinking of running
> > both create index statements at the same time from different sqlplus
> > sessions and hoping that the data for the slower statement is in
> > cache for the faster statement.

>
> > Or as an alternative, I was thinking of first creating an index which
> > was a superset of the columns in the other 2 indexes and then creating
> > the other indexes. They will just use the first index instead of
> > doing table scans. When they are done, drop the first index.

>
> > I'm hoping that someone else has better ideas or that there is just a
> > simpler way.

>
> > . . . Tom

>
> Tom,
>
> Is the table partitioned? (enterprise edition + partitioning option
> required)
> What degree of parallelism is set for the table? (if any)
> What version of the Oracle database server software are you referring
> to?
> What is the maximum OS IO size that is supported? (e.g. 1 MB)
> What is the db_file_multiblock_read_count set to? (e.g. 16)
> Have you gathered system stats under workload? (check sys.aux_stats$)
> This would enable cpu costing.
> The db_block_size would also be of interest, as would the tablespace
> block size if it differs from the db_block_size.
> (assume that it is 8192 bytes, but being a DW it might be 16K)
>
> Perhaps the limiting factor is that the dbfmbrc is only say 8, but
> could be set to 128 and grab a full 1 MB of data in a single IO call
> (show parameter db_file)
> Perhaps the limiting factor is that the pga_area_size is smallish
> causing a small sort_area_size to be used during index creation.
>
> If you're looking to make table scan and sorting operations cheaper
> (and go faster) you might consider the following:
> alter session set workarea_size_policy='MANUAL';
> alter session set db_file_multiblock_read_count=128;
> alter session set sort_area_size=536870912;
>
> Larger values for sort_area_size would likely be helpful.
> You might be limited on available physical memory.
>
> If other user sessions are working with blocks from the heap table,
> the likelihood of obtaining a large number of blocks from an extent in
> a single read decreases.
> Although it seems that accessing the blocks of the table at the same
> time would reduce the runtime of the 2 index creations due to having
> more blocks of that segment in memory, its much more likely that it
> would cause contention and cause the effective dbfmbrc to be reduced
> and the overall runtime to increase.
>
> Hopefully you have a good test environment in which to test for
> yourself.
>
> -bdbafh


"pga_area_size"
meant pga_aggregate_target.
oops.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-16-2008, 01:39 PM
Jonathan Lewis
 
Posts: n/a
Default Re: Faster index creation


"Tom" <tzeblisky@autooneins.com> wrote in message
news:889e1efa-7a65-4df5-b043-590a1c1e690b@k13g2000hse.googlegroups.com...
>I need to create 2 indexes on a 107 GB table. The indexes have no
> columns in common. I have a 8 Gig SGA.
>
> I am not looking forward to 2 tablescans so I was thinking of running
> both create index statements at the same time from different sqlplus
> sessions and hoping that the data for the slower statement is in
> cache for the faster statement.
>
> Or as an alternative, I was thinking of first creating an index which
> was a superset of the columns in the other 2 indexes and then creating
> the other indexes. They will just use the first index instead of
> doing table scans. When they are done, drop the first index.
>
> I'm hoping that someone else has better ideas or that there is just a
> simpler way.
>
> . . . Tom



Which version ?

If it's older than 10.2 then you'll be using the old sort option,
which is very CPU intensive and CPU may (silly though it sounds)
be more important than the simple cost of a large disc read.

You've got an 8Gb SGA, so I assume this means a 64bit machine.
If you allow about 36 bytes overhead per row plus the sum of
the average columns sizes in the index plus 2 x number of columns.
That will give you an indication of the size of the pga memory
you will need to complete the sort in memory.

If you can't do it in memory, the amount of I/O involved will be
the same regardless if you can do a one-pass sort - and the smaller
the memory usage is, the less CPU you use ... and that can make a
big difference to elapsed time.


--
Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com

Author: Cost Based Oracle: Fundamentals
http://www.jlcomp.demon.co.uk/cbo_book/ind_book.html

The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-16-2008, 01:39 PM
Tom
 
Posts: n/a
Default Re: Faster index creation

On May 14, 2:43*pm, "Jonathan Lewis" <jonat...@jlcomp.demon.co.uk>
wrote:
> "Tom" <tzebli...@autooneins.com> wrote in message
>
> news:889e1efa-7a65-4df5-b043-590a1c1e690b@k13g2000hse.googlegroups.com...
>
>
>
>
>
> >I need to create 2 indexes on a 107 GB table. *The indexes have no
> > columns in common. *I have a 8 Gig SGA.

>
> > I am not looking forward to 2 tablescans so I was thinking of running
> > both create index statements at the same time from different sqlplus
> > sessions and hoping that *the data for the slower statement is in
> > cache for the faster statement.

>
> > Or as an alternative, I was thinking of first creating an index which
> > was a superset of the columns in the other 2 indexes and then creating
> > the other indexes. *They will just use the first index instead of
> > doing table scans. *When they are done, drop the first index.

>
> > I'm hoping that someone else has better ideas or that there is just a
> > simpler way.

>
> > . . . Tom

>
> Which version ?
>
> If it's older than 10.2 then you'll be using the old sort option,
> which is very CPU intensive and CPU may (silly though it sounds)
> be more important than the simple cost of a large disc read.
>
> You've got an 8Gb SGA, so I assume this means a 64bit machine.
> If you allow about 36 bytes overhead per row plus the sum of
> the average columns sizes in the index plus 2 x number of columns.
> That will give you an indication of the size of the pga memory
> you will need to complete the sort in memory.
>
> If you can't do it in memory, the amount of I/O involved will be
> the same regardless if you can do a one-pass sort - and the smaller
> the memory usage is, the less CPU you use ... and that can make a
> big difference to elapsed time.
>
> --
> Regards
>
> Jonathan Lewishttp://jonathanlewis.wordpress.com
>
> Author: Cost Based Oracle: Fundamentalshttp://www.jlcomp.demon.co.uk/cbo_book/ind_book.html
>
> The Co-operative Oracle Users' FAQhttp://www.jlcomp.demon.co.uk/faq/ind_faq.html- Hide quoted text -
>
> - Show quoted text -



Thank you all!! It is always humbling to realize how little I know.

To answer a few of your questions:

Is the table partitioned? - No
What degree of parallelism is set for the table? - none
What version of the Oracle database server software? - 10.2
What is the maximum OS IO size that is supported? (e.g. 1 MB) - I
don't know
What is the db_file_multiblock_read_count set to? (e.g. 16) - it is 16
Have you gathered system stats under workload? - I don't think so but
the workload should be minimal there will be no end-users.
The db_block_size would also be of interest, as would the tablespace
block size if it differs from the db_block_size. - db block size is 8k
I'm not sure what the tablespace block size is.

To give a little more background information - we are moving a DB from
Sun to Linux. In the process, we are dropping and re-creating the
indexes. Most of them are fast - this particular one is not. I do
not own the DB but was putting in my two cents to try to help speed
things up. I now have a good amount of research to do - but that's OK!

Thank you all again!

. . . Tom
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-16-2008, 01:39 PM
Mladen Gogala
 
Posts: n/a
Default Re: Faster index creation

On Wed, 14 May 2008 10:33:24 -0700, Mark D Powell wrote:

> I would set work area management policy to manual, set the largest
> practical sort_area_size possible and just run one index build at a
> time.


This no longer applies to 10.2 and later. There is a new sort algorithm
in 10.2, specifically rewritten to make use of larger memories, available
through PGA_AGGREGATE_TARGET. There is a paper about this here:
http://tinyurl.com/5hc3l



--
http://mgogala.freehostia.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-16-2008, 01:39 PM
Mladen Gogala
 
Posts: n/a
Default Re: Faster index creation

On Wed, 14 May 2008 10:33:24 -0700, Mark D Powell wrote:


> I would set work area management policy to manual, set the largest
> practical sort_area_size possible and just run one index build at a
> time.


That wouldn't be advisable in case of Oracle 10.2. It has a new and
improved sorting algorithm, specifically improved to use large memory
areas and dynamic PGA memory.



--
http://mgogala.freehostia.com
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:23 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 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535