Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 10:03 AM
Emilia Venturato
 
Posts: n/a
Default BUG #2481: select from table's join with geometries doesn't go


The following bug has been logged online:

Bug reference: 2481
Logged by: Emilia Venturato
Email address: venturato@faunalia.it
PostgreSQL version: 8.1.4
Operating system: Debian etch
Description: select from table's join with geometries doesn't go
Details:

--I have data about animals in a table:

\d small_carnivore_fisso;
Tabella "public.small_carnivore_fisso"
Colonna | Tipo | Modificatori
-------------------+-------------------+--------------
id | integer |
family | character varying |
genus | character varying |
species | character varying |
common_name | character varying |
riscrit | character varying |
red_list_cat_desc | character varying |
ecoregion_code | character varying |

-- I have geographical data about animal in the table:
\d wwf_terr_ecos_multigeom
Tabella "public.wwf_terr_ecos_multigeom"
Colonna | Tipo | Modificatori
----------+-----------------------+--------------
eco_code | character varying(50) |
eco_name | character varying(99) |
the_geom | geometry |


-- a join without geometry goes well:
select a.*, b.eco_code from small_carnivore_species a join
wwf_terr_ecos_multigeom b on a.ecoregion_code=b.eco_code;


-- a join with geometry doesn't:

select a.*, b.the_geom from small_carnivore_fisso a join
wwf_terr_ecos_multigeom b on a.ecoregion_code=b.eco_code;
Segmentation fault

-- the geometries are valid
select isvalid(the_geom) from wwf_terr_ecos_multigeom where
isvalid(the_geom) is false;
isvalid
---------
(0 righe)


-- if I use 'create table as...' instead only select, the table is done:
create table foo as select a.*, b.the_geom from small_carnivore_fisso a join
wwf_terr_ecos_multigeom b on a.ecoregion_code=b.eco_code;
SELECT


If I reduce the record number the select sometime goes, sometime doesn't. I
cannot define a record limit wich make the difference.
Postgis developper said it could be a postgresql bug.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 10:03 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

"Emilia Venturato" <venturato@faunalia.it> writes:
> Postgis developper said it could be a postgresql bug.


Or it could be a postgis bug. Without a test case we can use to
reproduce the problem, it's all speculation. Please send a complete,
self-contained test case...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 10:03 AM
Michael Fuhr
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

On Thu, Jun 15, 2006 at 11:48:37PM -0400, Tom Lane wrote:
> "Emilia Venturato" <venturato@faunalia.it> writes:
> > Postgis developper said it could be a postgresql bug.

>
> Or it could be a postgis bug. Without a test case we can use to
> reproduce the problem, it's all speculation. Please send a complete,
> self-contained test case...


This report resembles a message Emilia posted in postgis-users a
couple of weeks ago. The only public discussion is a request for
the PostGIS version and copy of the data:

http://postgis.refractions.net/piper...ne/012281.html
http://postgis.refractions.net/piper...ne/012282.html

Emilia, did you and Sandro (strk) have off-list discussion about
this problem? What do version() and postgis_full_version() return?
What happens if you select the geometry column without a join, i.e.,
"SELECT the_geom FROM wwf_terr_ecos_multigeom WHERE ..."? Do you
get the segmentation fault with the original query if you select
AsText(the_geom) or AsEWKT(the_geom) instead of just the_geom?

Did the segmentation fault leave a core dump in your $PGDATA directory
or somewhere beneath it? If not then you might need to adjust your
coredumpsize resource limit.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 10:03 AM
Michael Fuhr
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

On Fri, Jun 16, 2006 at 11:16:50AM +0200, Emilia Venturato wrote:
> > Did the segmentation fault leave a core dump in your $PGDATA directory
> > or somewhere beneath it? If not then you might need to adjust your
> > coredumpsize resource limit.

>
> I understand it was psql to crash, not postgresql. Postgres doesn't stop.
> Maybe this could explain why create table go well and only select doesn't go.


Did psql create a core dump? If not then check your coredumpsize
resource limit. For example, if you're using bash, then what's the
output of "ulimit -c"? If it's 0 then run "ulimit -c unlimited".
With a core dump you can use a debugger to get a stack trace that
should show where the problem is.

> Making test I found also that query plan changes if I select geometric field
> or not. Particulary It seems have problem with merge condition:


The query plan shouldn't affect psql's behavior but selecting
different columns might. Notice that the estimated column width
is much higher when you select the geometry column than when you
don't:

[with]
> Merge Join (cost=1184.56..1415.71 rows=9222 width=78224) (actual
> time=259.035..355.384 rows=18444 loops=1)


[without]
> Hash Join (cost=52.67..483.28 rows=9222 width=113) (actual time=3.113..28.000
> rows=18444 loops=1)


> I prepared a file.zip with problem summary and data. It's 16 Mb. It's
> downloadable from http://www.faunalia.it/download/bug2481.tar.gz


A HEAD request against that file shows it to be 116M (121747346),
not 16M, and it appears to be on a slow link (curl estimates over
an hour to download). Can you create a smaller test case?

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 10:03 AM
Michael Fuhr
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

On Fri, Jun 16, 2006 at 06:53:28AM -0600, Michael Fuhr wrote:
> The query plan shouldn't affect psql's behavior but selecting
> different columns might. Notice that the estimated column width
> is much higher when you select the geometry column than when you
> don't:
>
> [with]
> > Merge Join (cost=1184.56..1415.71 rows=9222 width=78224) (actual
> > time=259.035..355.384 rows=18444 loops=1)


That's a lot of data -- are you aware that psql (via libpq) fetches
the entire result set before displaying it? In most cases 18444
rows wouldn't be a problem, but with rows that wide it becomes a
big problem because the client has to store it all in memory. I
wonder if that's causing psql to segfault, although I'd expect a
graceful error like "out of memory for query result" unless maybe
psql consumes so much memory that the OS has problems. How much
memory does the box have and what's your datasize resource limit?

Do you get the segfault if you LIMIT the result set to a small
number of rows? If you really need all that data then try using a
cursor so you can fetch data a few rows at a time instead of all
at once.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 10:04 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

Michael Fuhr <mike@fuhr.org> writes:
> That's a lot of data -- are you aware that psql (via libpq) fetches
> the entire result set before displaying it? In most cases 18444
> rows wouldn't be a problem, but with rows that wide it becomes a
> big problem because the client has to store it all in memory. I
> wonder if that's causing psql to segfault, although I'd expect a
> graceful error like "out of memory for query result" unless maybe
> psql consumes so much memory that the OS has problems.


I'm wondering the same --- psql is definitely designed to survive
out-of-memory:

regression=# select * from tenk1 a, tenk1 b limit 2000000;
-- time passes ...
out of memory for query result
regression=#

Emilia might have found some corner case where it doesn't, though;
perhaps a malloc call that's not error-checked. A stack trace from
the psql core dump would be useful.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-10-2008, 10:04 AM
Tom Lane
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

Emilia Venturato <venturato@faunalia.it> writes:
> Alle 16:18, venerdì 16 giugno 2006, Tom Lane ha probabilmente scritto:
>> Emilia might have found some corner case where it doesn't, though;
>> perhaps a malloc call that's not error-checked. A stack trace from
>> the psql core dump would be useful.


> Core dump is not generated.
> How can I generate a back-trace?


You probably need to adjust your "ulimit -c" setting to get a core dump
to be generated. Alternatively and maybe faster, just run psql under
gdb to start with:

$ gdb /path/to/psql
gdb> run arguments-for-psql-go-here
... interact with psql normally, provoke crash
gdb will report SIGSEGV and give you a prompt:
gdb> bt
... stack trace printed here ...
gdb> quit
$

If the stack trace contains only numeric addresses then it won't be any
help; in that case please recompile psql with debugging support so you
can get a useful trace.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-10-2008, 10:04 AM
Emilia Venturato
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

Alle 07:36, venerdì 16 giugno 2006, hai probabilmente scritto:
> On Thu, Jun 15, 2006 at 11:48:37PM -0400, Tom Lane wrote:
> > "Emilia Venturato" <venturato@faunalia.it> writes:
> > > Postgis developper said it could be a postgresql bug.

> >
> > Or it could be a postgis bug. Without a test case we can use to
> > reproduce the problem, it's all speculation. Please send a complete,
> > self-contained test case...

>
> This report resembles a message Emilia posted in postgis-users a
> couple of weeks ago. The only public discussion is a request for
> the PostGIS version and copy of the data:
>
> http://postgis.refractions.net/piper...une/012281.htm
>l
> http://postgis.refractions.net/piper...une/012282.htm
>l
>
> Emilia, did you and Sandro (strk) have off-list discussion about
> this problem?


Yes, we had off-list discussion.

> What do version() and postgis_full_version() return?


version
----------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.4 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.0.4
20060507 (prerelease) (Debian 4.0.3-3)

postgis_full_version
------------------------------------------------------------------------------------------------------------------
POSTGIS="1.1.2" GEOS="2.2.1-CAPI-1.0.1" PROJ="Rel. 4.4.9, 29 Oct 2004"
USE_STATS (procs from 1.1.1 need upgrade)

> What happens if you select the geometry column without a join, i.e.,
> "SELECT the_geom FROM wwf_terr_ecos_multigeom WHERE ..."?


It goes well.

> Do you
> get the segmentation fault with the original query if you select
> AsText(the_geom) or AsEWKT(the_geom) instead of just the_geom?


I tried with astext and it's doesn't go.

> Did the segmentation fault leave a core dump in your $PGDATA directory
> or somewhere beneath it? If not then you might need to adjust your
> coredumpsize resource limit.


I understand it was psql to crash, not postgresql. Postgres doesn't stop.
Maybe this could explain why create table go well and only select doesn't go.


Making test I found also that query plan changes if I select geometric field
or not. Particulary It seems have problem with merge condition:

-- If I make select with geometric field:

select a.*, b.the_geom from small_carnivore_fisso a join
wwf_terr_ecos_multigeom b on a.ecoregion_code=b.eco_code;


QUERY PLAN
Merge Join (cost=1184.56..1415.71 rows=9222 width=78224) (actual
time=259.035..355.384 rows=18444 loops=1)
Merge Cond: (("outer".eco_code)::text = "inner"."?column9?")
-> Index Scan using index_eco_code on wwf_terr_ecos_multigeom b
(cost=0.00..98.97 rows=1654 width=78131) (actual time=16.307..51.607
rows=1653 loops=1)
-> Sort (cost=1184.56..1207.62 rows=9222 width=103) (actual
time=242.567..259.277 rows=18443 loops=1)
Sort Key: (a.ecoregion_code)::text
-> Seq Scan on small_carnivore_fisso a (cost=0.00..269.22
rows=9222 width=103) (actual time=11.380..75.130 rows=9222 loops=1)
Total runtime: 363.247 ms


-- without geometric field:

QUERY PLAN
Hash Join (cost=52.67..483.28 rows=9222 width=113) (actual time=3.113..28.000
rows=18444 loops=1)
Hash Cond: (("outer".ecoregion_code)::text = ("inner".eco_code)::text)
-> Seq Scan on small_carnivore_fisso a (cost=0.00..269.22 rows=9222
width=103) (actual time=0.013..7.099 rows=9222 loops=1)
-> Hash (cost=48.54..48.54 rows=1654 width=10) (actual time=3.002..3.002
rows=1654 loops=1)
-> Seq Scan on wwf_terr_ecos_multigeom b (cost=0.00..48.54
rows=1654 width=10) (actual time=0.008..1.414 rows=1654 loops=1)
Total runtime: 34.492 ms


I prepared a file.zip with problem summary and data. It's 16 Mb. It's
downloadable from http://www.faunalia.it/download/bug2481.tar.gz

Thank you very much.
Lia



--
Emilia Venturato
email+jabber: venturato@faunalia.it
www.faunalia.it
Tel: (+39) 347-2770007 Tel+Fax: (+39) 0587-213742
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-10-2008, 10:04 AM
Emilia Venturato
 
Posts: n/a
Default Re: BUG #2481: select from table's join with geometries doesn't go

Alle 16:18, venerdì 16 giugno 2006, Tom Lane ha probabilmente scritto:

>
> Emilia might have found some corner case where it doesn't, though;
> perhaps a malloc call that's not error-checked. A stack trace from
> the psql core dump would be useful.
>
> regards, tom lane


Core dump is not generated.
How can I generate a back-trace?

ciao
Lia

--
Emilia Venturato
email+jabber: venturato@faunalia.it
www.faunalia.it
Tel: (+39) 347-2770007 Tel+Fax: (+39) 0587-213742
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

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 11:19 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 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588