• DB Guy (unregistered) in reply to Outlaw Programmer

    I second that. TRWTF is filtering data out AFTER having returned it from the database. Databases are here to return either what you want, or nothing.

  • shimon (unregistered) in reply to GalacticCowboy
    Huh... and here I thought the article was talking about the results being based on a single city... Unless your city is 100 miles wide?

    And now imagine for a moment that my city is somewhere far to the North. Say, Alaska, or Siberia.

  • Ephemeriis (unregistered)

    Holy hell, did Greg go into hardware support?

    We do hardware support, not software development... But I've got a technician just like Greg. We'll give him an easy task, outline how it should be done, and he manages to turn it into the biggest mess imaginable.

    I'm currently in the process of cleaning up after one of his disasters...

  • AdT (unregistered) in reply to shimon
    shimon:
    And now I have a piece of breaking news for you: the Earth, as the recent researches have shown, is not flat at all!

    I was sort of expecting a nonsensical comment like this. Locally, the difference between flat and spherical (I know, I know, the Earth is not a sphere either) topology is negligible. Even a simple parallel projection will work well.

    Note that I intentionally left out taking the square root to determine the distance. Yes, distances will be inaccurate, but the relative magnitude of them will be quite accurate.

    shimon:
    And it's enough for the endpoints to be two or three states apart for cartesian distance to go from simply inaccurate to f-cking wildly inaccurate.

    You mean when I search for hotels in NYC, my logic isn't able to accurately tell which of

    A) a hotel in Oregon B) a hotel in SoCal

    is closer to the target? F***ing big deal. Even an international hotel reservation system can easily be implemented using a flat map if the borders and projection method are chosen wisely because all relevant distances will be on the order of a few miles anyway.

    Futhermore, observe GalacticCowboy's comment. You can waste as much (computation) time as you want on some super accurate geoidal surface distance estimator (taking terrain heights into account...), but it will still be a proxy for what the user really wants to know: How long it will take to get from the target location to the hotel, and how much it will cost. A full-blown route calculation is, however, computationally expensive and there may also be substantial license fees involved.

  • Stig (unregistered) in reply to DB Guy
    DB Guy:
    I second that. TRWTF is filtering data out AFTER having returned it from the database. Databases are here to return either what you want, or nothing.
    There could be any number of reasons why you would need to perform some form of post-process on a result set.
  • shimon (unregistered) in reply to Ephemeriis
    We do hardware support, not software development... But I've got a technician just like Greg. We'll give him an easy task, outline how it should be done, and he manages to turn it into the biggest mess imaginable.

    I'm currently in the process of cleaning up after one of his disasters...

    If he is not an idiot, some parking lot therapy may help. Sometimes it's better than costs of seeking a new guy which might be worse.

  • (cs) in reply to My Name
    My Name:
    Kazan:
    hint: they only need to be session-unique.

    You should also include the full query, to make it easier to share the link. What if I wanted to visit a city with my friends, and wanted to share the link to the search results? Unless the search id is unique, and you store it for a long time, this won't work.

    The best choice (IMHO) would be to include both a search id and all query parameters. If the search id is an active search, get the results from the session. If not, query the database and build the results again.

    People like to share links. The worst example of this, is a book store I once saw. Each link was actually a javascript postback call, and the link to the book was not a nice semantic URL, but a releative referance. The link was searchresults.aspx?item=2 (where 2 was the position of the book in the search...)

    fair point :D

  • (cs) in reply to uzytkownik
    uzytkownik:
    shimon:
    ORDER BY SQUARE(hotels.x - @locationX) + SQUARE(hotels.y - @locationY) ASC

    QED (What to do if there is no SQUARE function is left as an exercise to the reader.)

    And now I have a piece of breaking news for you: the Earth, as the recent researches have shown, is not flat at all!

    And it's enough for the endpoints to be two or three states apart for cartesian distance to go from simply inaccurate to f-cking wildly inaccurate.

    I've never been in US but I guess most of the cities can be considered as flat(resonable small curvature can be locally mapped to flat - hence the human mistakes about flatness of earth/spacetime). Those which don't usually needs to be separated - why would I want a hotel in another state?

    most peolpe want driving distances. and driving distance can be MUCH LARGER than crow-flies distance.

  • (cs) in reply to shimon
    shimon:
    Or you can do the sane thing and delegate the whole problem to some expert piece of software written by people who have to actually do this for a living. Whoops! That's outside the DB...

    Well you can cache that.

    And, after all, it is approximate. It is supposed to be approximate.

    no you can't you bleeding moron. yuo don't have infinite freaking storage space and infinite CPU time to write EVERY POSSIBLE source location mapped to every hotel in your database.

    STOP ACTING LIKE EVERYTHING IS LIKE YOUR COMPUTER SCIENCE 100 COURSE HOMEWORK!

    Fark i hated morons who had no outside world experience when I was in university, i hate them even more now. i have to clean up their messes now.

  • Paul N (unregistered)
    The final page said it had six, but actually had zero. And on top of that, they weren't sorted correctly.
    The real wtf is the zero results on the final page weren't sorted correctly.
  • shimon (unregistered) in reply to AdT
    A full-blown route calculation is, however, computationally expensive and there may also be substantial license fees involved.
    http://www.movable-type.co.uk/scripts/latlong-vincenty.html

    With this little function, you can calculate geodesic distances with accuracy within 0.5mm. For free. Still better than unprojected cartesian. Still giving you something comparable no matter how close to a pole you are.

  • (cs) in reply to AdT
    AdT:
    what the user really wants to know: How long it will take to get from the target location to the hotel, and how much it will cost. A full-blown route calculation is, however, computationally expensive and there may also be substantial license fees involved.

    A* on a road shapefile.

    Hint: those shape files can be acquired free/very cheap from the USGS. I implemented a road conditions map using them.

    Hint 2: Implement A* in a DB? pfftt

  • (cs) in reply to shimon
    shimon:
    A full-blown route calculation is, however, computationally expensive and there may also be substantial license fees involved.
    http://www.movable-type.co.uk/scripts/latlong-vincenty.html

    With this little function, you can calculate geodesic distances with accuracy within 0.5mm. For free. Still better than unprojected cartesian. Still giving you something comparable no matter how close to a pole you are.

    and you're still, in your ignorance of actual user desires, still performing crow-flies calculations.

    The User wants driving/walking/bussing directions. That involves using the A* algorithm on a network[see note] graph.

    Note: the 'network' in this case is road/sidewalk/bus/subway watever - transit network.

  • Miksu (unregistered) in reply to Kazan
    Kazan:
    most peolpe want driving distances. and driving distance can be MUCH LARGER than crow-flies distance.

    When booking a hotel from another city I for one am much more interested in knowing the hotel's distance from some clear landmarks in the city than the driving distance from point A. The driving distance doesn't give me any idea about the hotel's location within the city whereas the distance from say Times Square tells a lot more.

  • shimon (unregistered) in reply to Kazan
    STOP ACTING LIKE EVERYTHING IS LIKE YOUR COMPUTER SCIENCE 100 COURSE HOMEWORK!

    Fark i hated morons who had no outside world experience when I was in university, i hate them even more now. i have to clean up their messes now.

    Darn, I'm starting to like this kind of behavior: take a random comment and make it look like a personal insult. Start screaming and naming names.

  • Yup (unregistered) in reply to Big Bad Bear
    Big Bad Bear:
    Dave C.:
    And so once again we learn: Check up often on the new guy.
    Or to put it another way: design reviews, design reviews, design reviews!

    What? No design to review? FAIL! Prove to me you understand the problem and have a usable solution, or BEGONE!

    Forcing the goat of our story to explain how he intended to solve the problem would have snuffed that hideous, convoluted, EVIL flowchart in the cradle.

    In general I agree however, this appears to be a case of not following directions. There was nothing to design. Bruno explicitly says, "Just remember to run the front-end filters before sending the data to PEAR::Pager." Run a query, filter the data and send to a plugin. Done.

  • (cs) in reply to Miksu
    Miksu:
    Kazan:
    most peolpe want driving distances. and driving distance can be MUCH LARGER than crow-flies distance.

    When booking a hotel from another city I for one am much more interested in knowing the hotel's distance from some clear landmarks in the city than the driving distance from point A. The driving distance doesn't give me any idea about the hotel's location within the city whereas the distance from say Times Square tells a lot more.

    still driving distance.

  • Observer (unregistered) in reply to Code Dependent
    Code Dependent:
    Kazan:
    ...and the only sane way of updating that data is on-demand [and not bother storing it in the DB at all] since it can change in real time
    The hotel location changes in real time?
    Observer:
    Also, hotels needed to be sorted by distance which could not be a part of the SQL query
    Why not? What information do they have in the front end that can't be included in the query?

    Here's a fundamental difference in the way I read the stories and the way a lot of other people read them. If the story states that they need to get the list from the database and THEN filter the results, I take that at face value. We're not in some textbook perfect world and NONE OF YOU have ANY idea how their system really works. You have NO idea what you're talking about -- it's all wild speculation. If the story states that the results must be filtered after the query, I take that as fact because I don't have enough REAL knowledge to refute it.

    If you want to come up with interesting ways that they could organize the system to avoid the front-end processing, then go for it, but don't argue with others using your speculation...

    Oh, and the other guy was talking about availability changing in real time -- not some RV-cluster-hotel that roams around the country...

  • (cs) in reply to shimon
    shimon:
    STOP ACTING LIKE EVERYTHING IS LIKE YOUR COMPUTER SCIENCE 100 COURSE HOMEWORK!

    Fark i hated morons who had no outside world experience when I was in university, i hate them even more now. i have to clean up their messes now.

    Darn, I'm starting to like this kind of behavior: take a random comment and make it look like a personal insult. Start screaming and naming names.

    you can be annoyed with someone's idiocy without being personally insulted by them you know.

    but then there I go again expected you, a poster on TDWTF, to have enough intelligence to realize things.

    if you don't know the first thing about real world programing GTFO already.

    If you do know the first thing about real world programming stop acting like an idiot and thinking that EVERYTHING can be done in data storage*.

    • and yes a DB - even a good RDBMS is a data storage and retrieval system. it is NOT for running programs.
  • shimon (unregistered) in reply to Observer
    Here's a fundamental difference in the way I read the stories and the way a lot of other people read them. If the story states that they need to get the list from the database and THEN filter the results, I take that at face value. We're not in some textbook perfect world and NONE OF YOU have ANY idea how their system really works. You have NO idea what you're talking about -- it's all wild speculation. If the story states that the results must be filtered after the query, I take that as fact because I don't have enough REAL knowledge to refute it.
    The point of these stories are that they, apart from some educational value, are entertaining. And it is entertaining to us to squish every juice of humor from these stories, to find more real WTFs than the story tells, then to find entertainment in commenting and comments from others. This is called humor, after all.
  • (cs) in reply to shimon
    shimon:
    Here's a fundamental difference in the way I read the stories and the way a lot of other people read them. If the story states that they need to get the list from the database and THEN filter the results, I take that at face value. We're not in some textbook perfect world and NONE OF YOU have ANY idea how their system really works. You have NO idea what you're talking about -- it's all wild speculation. If the story states that the results must be filtered after the query, I take that as fact because I don't have enough REAL knowledge to refute it.
    The point of these stories are that they, apart from some educational value, are entertaining. And it is entertaining to us to squish every juice of humor from these stories, to find more real WTFs than the story tells, then to find entertainment in commenting and comments from others. This is called humor, after all.

    you're not finding WTFs though, you're creating new ones with your "everything should be done in the database"

    NO. IT SHOULD NOT.

    A database is a highly efficient data storage and retrieval system. Full stop. it is NOT supposed to do anything but data storage and retrieval. Just because you can abuse stored procedures, etc to do things that should be done in code doesn't mean you should.

    Almost every real world "distance between two points"[see note] is done in distances on the transportation network. That means performing A* on a network graph. I could imagine that you could abused stored procedures on a DB into being able to do that but I would fire you for it.

    The Clever solution is never better than the Correct Solution.

    note: on travel websites.

  • shimon (unregistered) in reply to Kazan
    * and yes a DB - even a good RDBMS is a data storage and retrieval system. it is NOT for running programs.

    AND retrieval RETRIEVAL

    Specifying a constraint in a retrieval phase is a bit of programming already.

    You know, people have invented views and stored procedures for a reason. If some theoretical drone comes up to me and says, you cannot do that, because it's a <CONCEPT> and this <CONCEPT> was not meant to do that — I slap him in the face. Because I don't care about high matters and academic works on the <CONCEPT>, if bending a rule in one place will simplify a hundred more places, make me twice as efficient and contribute to my wallet.

    This is what the real world acts like if you wanted to hear from me.

  • Observer (unregistered) in reply to Kazan
    Kazan:

    still driving distance.

    If I go to Hotels.com and search for a hotel close the the convention center in Anywhere, USA, I seriously doubt the hotel distances are going to be listed using driving directions...

    A simple as the crow flies radius is the only thing that's important. Also, the curvature of the Earth is irrelevant because if I live in LA and I want a hotel in Chicago, I really don't care how far away the hotel is from LA!! I want to know how far it is from landmarks in the city. And then, as long as all the hotels are using the same calculation (and they would) the relative differences between competing hotels will be valid even if the real differences from the landmarks are slightly underestimated because of any curvature... and I mean very slight.

  • (cs) in reply to Kazan
    Kazan:
    no you rube, MySQL/Postgress/M$ SQL/etc cannot do A* on a road map.

    learn to program dimwit. ... no you can't you bleeding moron.

    STOP ACTING LIKE EVERYTHING IS LIKE YOUR COMPUTER SCIENCE 100 COURSE HOMEWORK!

    Fark i hated morons who had no outside world experience when I was in university, i hate them even more now. i have to clean up their messes now. ... and you're still, in your ignorance of actual user desires, still performing crow-flies calculations.

    The User wants driving/walking/bussing directions. That involves using the A* algorithm on a network[see note] graph.

    Woke up horny this morning and she wouldn't go along, huh? Aw, darn, that's too bad. Have a cup of coffee, man.

    So you once used an A* algorithm. That means... wowie zowie... you can really program!!!1111!! Gosh...

  • someguy (unregistered) in reply to Kazan
    Kazan:
    Outlaw Programmer:
    Here's The Real WTF:
    The logic used to calculate distances, for instance, was handled by the front end, as well as real-time checks for vacancies would affect the sorting and remove some results from whatever was returned from the database.

    Any time your webapp features the term "logic handled by the front-end," you're probably doing something wrong. I don't see any reason why their server couldn't have done these things. The new guy should have slapped Bruno before starting the project.

    By "Front End" I'm going go say he meant "Their PHP Code" not "Some Javascript in the webbrowser"

    so yes, their server is handling it.

    not everyone has the same exact definition of "Front end" and "back end". in much of web development the "back end" = storage/db and "front end" = your PHP, JSP, ASP.NET, whatever code.

    The php code is able to "massage" the list (presumably without more input), so that must mean that the app has all the data it needs to populate the list correctly. If that's the case, then why didn't he build the query to just return the results he wanted, rather than the whole list so that he could then iterate through in code?

  • (cs) in reply to shimon
    shimon:
    * and yes a DB - even a good RDBMS is a data storage and retrieval system. it is NOT for running programs.

    AND retrieval RETRIEVAL

    Specifying a constraint in a retrieval phase is a bit of programming already.

    You know, people have invented views and stored procedures for a reason. If some theoretical drone comes up to me and says, you cannot do that, because it's a <CONCEPT> and this <CONCEPT> was not meant to do that — I slap him in the face. Because I don't care about high matters and academic works on the <CONCEPT>, if bending a rule in one place will simplify a hundred more places, make me twice as efficient and contribute to my wallet.

    This is what the real world acts like if you wanted to hear from me.

    did i say retrieval was completely a-programatic?

    nope.

    however you should never make a database system do anything that isn't related to data retrieval. A* isn't data retrieval. Calculating a Geodeisic distance isn't data retrieval.

    you're going to spend more time creating a Clever Solution to do those things in SPs than it is worth in $ and execution time.

    You know what the best thing about stored proceedures is?

    You only have to run the query optimizer once, when you save the proceedure. That over a lot of queries will save a LOT of compute time.

    The fact remains that if you have to retrieve data that you cannot make assumptions on the contents of [can change from moment to momenet] and you're not a "subscribed listener" to those changes you're going to have to do processing in code not the just the DB.

    The fact remains that if you have to filter your results based on things that require some execution time - such as A* searches, etc - you're going to have to do processing in code not just the DB.

    Yes use the most efficient solution, however massaging (abusing) the SP system to do something that would be coded faster in code [and would probably execute faster there too] is NOT the most efficient solution.

    [edit] yes.. i know the second best thing about stored procedures is security uses of them.

  • (cs) in reply to Code Dependent
    Code Dependent:
    Woke up horny this morning and she wouldn't go along, huh? Aw, darn, that's too bad. Have a cup of coffee, man.

    So you once used an A* algorithm. That means... wowie zowie... you can really program!!!1111!! Gosh...

    actually my wife and I had plenty of fun last night before bed thank you very much.

    I keep bringing up A* because it's the most commonly used solution to solving path finding. it's the de facto. Games use it, road directions use it, etc etc.

    I also keep bringing it up because it's something that shouldn't be massaged into a stinking stored procedure on a database.

    oh don't forget that it's relevant to the discussion at hand.

  • GT (unregistered)

    Dear people on your high horse about returning all the rows from the DB:

    You are not taking into consideration the domain of this application. A list of hotels (large, physical structures) is probably just not all that long, and really not all that much data to pull back. Its not like there is the potential for the table to have 50mm rows, and the list of hotels is pretty unlikely to change during a user's session.

  • Mayhem (unregistered) in reply to someguy
    someguy:
    <snip> .. some rants from Kazan et al .. </snip>

    The php code is able to "massage" the list (presumably without more input), so that must mean that the app has all the data it needs to populate the list correctly. If that's the case, then why didn't he build the query to just return the results he wanted, rather than the whole list so that he could then iterate through in code?

    The way I see it, the users probably want to see all results for a given area. They then want to play around with filtering the results based on price/distance/quality of hookers/pictures of rooms etc.
    I expect it is faster and less resource intensive based on historical user behaviour to cache the initial search results and quickly iterate through the smaller resultset than to requery the database every time they want to refine by something else.

  • (cs) in reply to Observer
    Observer:
    Code Dependent:
    Kazan:
    ...and the only sane way of updating that data is on-demand [and not bother storing it in the DB at all] since it can change in real time
    The hotel location changes in real time?
    Observer:
    Also, hotels needed to be sorted by distance which could not be a part of the SQL query
    Why not? What information do they have in the front end that can't be included in the query?
    *snip* You have NO idea what you're talking about -- it's all wild speculation. If the story states that the results must be filtered after the query, I take that as fact because I don't have enough REAL knowledge to refute it.

    If you want to come up with interesting ways that they could organize the system to avoid the front-end processing, then go for it, but don't argue with others using your speculation...

    Perhaps you should have a closer look at my words, quoted above. Particularly the punctuation marks at the ends. Note the difference between my quiet questioning and the arrogant cocksure assholiness of Kazan.

  • Spoe (unregistered) in reply to uzytkownik
    uzytkownik:
    I've never been in US but I guess most of the cities can be considered as flat(resonable small curvature can be locally mapped to flat - hence the human mistakes about flatness of earth/spacetime). Those which don't usually needs to be separated - why would I want a hotel in another state?

    Choosing an appropriate coordinate system is important here. Lat/Long won't cut it. The distance describe by one degree of latitude is constant; one degree of longitude, however, is not.

    You'd probably, if you only need crow flies measures, want to use lat long and apply the Haversine formula which is not terribly difficult. Doesn't include anything more difficult than trig functions.

  • Stig (unregistered)

    I can only speculate as to how unpleasant it must be to work with/for Kazan - with his obnoxious and bellicose attitude - I certainly wouldn't wish to employ him.

    His blinkered religious zealotry regarding the location of logic in an architecture is absurd. If experience teaches us anything, it must surely teach us that 'hard rules' often run into real-world situations that highlight their inapplicability.

    Frex....we have multiple platforms accessing the same database. Do we reimplement the A* algorithm in every platform, or do we push that logic down into the surface of the DBMS, thereby extending its query functionality? Or do we inject a common logic layer?

    The real WTF is your attitude, Kazan.

  • Banana Hammock (unregistered)

    MySQL does GIS: http://dev.mysql.com/tech-resources/articles/4.1/gis-with-mysql.html

  • ClassA (unregistered)

    WTF: Paginating a result set that is subject to live changes in hotel availability - the size of the result set can change between page views, leaving pagination page number/start index meaningless.

    Kazan:
    NO. IT SHOULD NOT.

    A database is a highly efficient data storage and retrieval system. Full stop. it is NOT supposed to do anything but data storage and retrieval. Just because you can abuse stored procedures, etc to do things that should be done in code doesn't mean you should.

    Rubbish.

    There are many compelling reasons to put "business logic" into the database:

    1. If more than one application, built on more than one technology, accesses the data (which is almost inevitable in a large system) then consistent logic is applied relating to absolute business rules as data is only manipulated by a transactional API which is defined in the database

    2. Security. No need to grant DELETE on APP_USERS as an API based on stored procedures does the work for you and perform authentication and security logic - no risk of a trashed database because of SQL injection

    3. Efficiency (potentially an enormous gain). Not returning any more data than nescessary over the network. Processing data "close to" the data and taking advantages of the RDBMS's set-based operations etc.

    4. Data integrity, consistency and proper transaction handling

    5. Unified and guarenteed logging and auditing of business transactions

    "things that should be done in code" - and a stored procedure isn't code? They can even be natively compiled nowadays.

    Personally, I'd advocate performing any logic that is universally applicable to all applications accessing the data IN THE DATABASE.

    Calling a web-service to check hotel availability (optionally caching in the database)? Sure, why not?

    A*? It's not a terribly complicated algorithm, could be fairly trivially implemented in a SP. Not the best idea if this is front-end "application" logic and not fundamental to the way the data is accessed.

    RDBMSs have had GIS/spatial processing capabilities for a while now...

    Kazan:
    You only have to run the query optimizer once, when you save the proceedure. That over a lot of queries will save a LOT of compute time

    This isn't even true - the execution plan isn't hard-wired at SP compile time. This would be a bad thing as the optimizer would never use a newly created index, for example.

    SPs can use variable binding to prevent re-parsing, but this would be true of a well-developed PHP application issuing direct SQL too.

  • Anon (unregistered) in reply to Kazan
    Kazan:
    uzytkownik:
    shimon:
    ORDER BY SQUARE(hotels.x - @locationX) + SQUARE(hotels.y - @locationY) ASC

    QED (What to do if there is no SQUARE function is left as an exercise to the reader.)

    And now I have a piece of breaking news for you: the Earth, as the recent researches have shown, is not flat at all!

    And it's enough for the endpoints to be two or three states apart for cartesian distance to go from simply inaccurate to f-cking wildly inaccurate.

    I've never been in US but I guess most of the cities can be considered as flat(resonable small curvature can be locally mapped to flat - hence the human mistakes about flatness of earth/spacetime). Those which don't usually needs to be separated - why would I want a hotel in another state?

    most peolpe want driving distances. and driving distance can be MUCH LARGER than crow-flies distance.

    Nonsense, if you need a hotel, then you are probably already driving a distance that is much greater than the differences between different hotels in your target city. Or else you are flying, in which case you not driving anyway. Crow-flies distances give you a quick estimation which is adequate for most purposes.

  • Patrick (unregistered)

    Holy Crap! I could have done that from scratch in less than an hour, it's not that difficult!

  • Smyle (unregistered)

    Listening to the bickering here, I've just come up with a great plan for deciding the best way to code a project when I have no idea where to start.

    I explain the problem in great detail, decide on the worst possible implementation, and post it to TDWTF. Let the one-upsmanship begin, and steal the best code posted.

  • (cs) in reply to Stig
    Stig:
    shimon:
    Better yet, roll your own webserver, CGI is for weenies.

    In the machine code.

    Typed in with a Morse key.

    Attaboy. That's the fightin' spirit we need ;)

    Solder your own motherboard together first and we'll talk fightin' spirit. Pussy...

    ;)

  • Sane Person (unregistered)

    Wow, talk about taking a simple problem and making it complicated.

    When I search for a hotel, I want to know which hotels are reasonably close to the airport that I will be arriving at, or to the place I will be visiting. A close approximation of this distance is fine. I don't need it accurate to the millimeter. Any hotel website I've ever visited shows it rounded off to the nearest tenth of a mile anyway. The difference between the approximation you get by pretending the world is flat to the closer approximation you get by pretending the world is a perfect sphere is going to be less than the rounding error anyway. And you are aware, are you not, that the world is not a perfect sphere? There's that bulge at the equater, and probably more significant on the scale we're talking about, there are hills and valleys all sorts of topographical features.

    I suppose there are cases when hotel A is slightly closer than hotel B as the crow files, but when you come to actually drive it, A is on the far side of a lake that you have to go around so it is actually farther away. But then, even if you had exact driving directions, it's possible that the hotel that is closer -- in real driving distance -- takes longer to get to because you have to travel on busier streets. Without knowing the exact time of day that the person plans to arrive so that you can anticipate commuter traffic, the exact timing of all traffic lights, knowing what the weather will be like that day and where there will be accidents or other traffic tie ups, there's no way to calculate all of this precisely. And no one cares.

    Do you do this with all your problems? Developing computer systems is tough enough without inventing all sorts of unnecessary requirements to add to what the user really wants.

  • Sane Person (unregistered)
    ps aux:
    http://php.about.com/od/mysqlcommands/g/Limit_sql.htm

    items = pageNumber * 10;

    LIMIT items, 10

    But note that that's a MySQL extension to the SQL standard. It doesn't work in most other SQL dialects. Some provide equivalent features, others don't.

  • (cs)

    This article reminds me of when I was house hunting online. You'd select "within 5 miles" and get somewhere halfway across the state. "within 1 mile" barely kept you in the city.

  • ollo (unregistered) in reply to shimon
    shimon:
    A full-blown route calculation is, however, computationally expensive and there may also be substantial license fees involved.
    http://www.movable-type.co.uk/scripts/latlong-vincenty.html

    With this little function, you can calculate geodesic distances with accuracy within 0.5mm. For free. Still better than unprojected cartesian. Still giving you something comparable no matter how close to a pole you are.

    ...and calculated in SQL so you can sort backend-side?

  • shimon (unregistered) in reply to ollo
    ...and calculated in SQL so you can sort backend-side?

    Vincenty distance? Sure thing. This is the reason for me to come up with that.

    If you, however, don't need the distance from an arbitrary point on Earth to the front doorbell of a hotel, but the distance from some common landmarks in the hotel's city, it gets fairly simple to store them all in the DB. Even if storage is scarce (hey, what is scarce? 120GB? 250GB?). And you even don't even need the formula. And, yes, all in SQL.

  • You want me to stay where? (unregistered) in reply to uzytkownik

    "...why would I want a hotel in another state?"

    Because my conference is in western Washington DC, and I could stay at a hotel in Virginia or Maryland.

  • (cs)

    Wow you guys are crazy. My original comment was that this guy shouldn't be mixing presentation with business logic. That's it. Who gives a shit if everything is done in the DB vs. some extra server-side processing? As long as the finalized result set gets delivered to the page responsible for rendering, I'm happy.

    I'm approaching this from the point of view where different pages do something similar and need some of the same filtering done. Just push this crap down into the one layer and be done with it.

  • Bryan (unregistered) in reply to dkf

    Yup, in the DC area a place that's 5 miles away can take over an hour to reach because it happens to be on the other side of the Potomac.

  • valderman (unregistered)
    MP:
    Forget that most posters have years of experience and/or a college education themselves.
    Most? Judging by the overall level of discussion and OMFG RETARDED APP IS TRWTF MY WAY IS SO MUCH BETTER-ness, I'd be surprised to learn that more than a handful are out of high school.
  • Stig (unregistered) in reply to jobrahms
    jobrahms:
    Stig:
    shimon:
    Better yet, roll your own webserver, CGI is for weenies.

    In the machine code.

    Typed in with a Morse key.

    Attaboy. That's the fightin' spirit we need ;)

    Solder your own motherboard together first and we'll talk fightin' spirit. Pussy...

    ;)

    ...and I'll bet you went for a romantic stroll with your boyfriend to shop for those components, didn't you? Real men would have crafted them from raw sand. Ya big girls blouse.

    ;)

  • Stig (unregistered) in reply to pitchingchris
    pitchingchris:
    This article reminds me of when I was house hunting online. You'd select "within 5 miles" and get somewhere halfway across the state. "within 1 mile" barely kept you in the city.
    Try various job sites that claim to be able to filter by 'miles from your zip code'....you get some odd results every now & then!
  • (cs) in reply to ClassA
    ClassA:

    This isn't even true - the execution plan isn't hard-wired at SP compile time. This would be a bad thing as the optimizer would never use a newly created index, for example.

    nothing i've said should be interpreted to contradict anything you said in points 1 through 5. If they did then you misinterpreted my statements rather egregiously.

    you could trigger SP recompile on index change.... :D my understanding is that is how a certain major open source database was doing it.

    As for the fact that some database programs do GIS? that's stupid. that's not their job.

    ==================================

    to the other posts who think that because I'm exercising my "bite people i consider idiots heads off" side on the internet means i must not be "very nice to work with" you're just being intentionally dense. just because i CAN bite your head off doesn't mean i'm GOING to bite your head off.

    In person to people I like I'm polite even if they're totally braindead. some random idiot on the net talking out their arse because their face knows better... not so much.

    and yes my 'attitude' that 'the appropriate tool should be used for the job' is COMPLETELY a "what the fuck" i mean.. who would EVER think to use the right tool for the job.
    Got a nail that needs pounded into place? let's use a drill!
    Got a hole that needs to be made? let's use a piece of sandpaper!

Leave a comment on “Pagination Consternation”

Log In or post as a guest

Replying to comment #:

« Return to Article