From: Dr Bob Jansen <bob.jansen@tu...> - 2010-11-09 04:24:14
Jason's comments are very timely for a project I am working on as we
have just decided to adopt the sequential number approach to provide
auto-generated page titles for many of our pages. We are also allowing
for 6 digit numbers, so a page could be called APage999998.
Any performance hit would be very detrimental to us.
Jason's proposed solution seems very simple and elegant. Yaron, any
chance of a fix along these lines?
On 09/11/2010 6:25 AM, semediawiki-user-request@... wrote:
> Message: 3
> Date: Mon, 08 Nov 2010 10:12:22 -0800
> From:"jiesheng@..." <jiesheng@...>
> Subject: [Semediawiki-user] unique number handling page tile
> generation in Semantic Form
> Cc: Semantic MediaWiki users<semediawiki-user@...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Hi, all
> I used<unique number> for title generation from Semantic Form.
> However, I found it is really inefficient. It logic is "cycle through
> numbers for this tag until we find one that gives a nonexistent page
> title". For small number of pages it is ok. But it will be slow if there
> are a lot of pages. Conceivably each "existing check" will trigger a sql
> query. You can image how slow it is if there are 10000 existing page for
> this form. The simple logic for unique number will trigger at least
> 10000 sql queries.
> I suggest a sequence generation from database to handle<unique number>
> in a form. By this way, looking up the unique number takes constant
> time. In mysql I do the sequence generation using a function
> First, I create table and function like this
> drop table if exists
> CREATE TABLE bt_seq
> name varchar(20) NOT NULL primary
> val integer UNSIGNED NOT
> delimiter //
> CREATE FUNCTION bt_seq(seq_name char (20)) returns int
> UPDATE bt_seq SET val=last_insert_id(val+1) WHERE name=seq_name;
> RETURN last_insert_id();
> delimiter ;
> In code, I retrieve the id like this :select bt_seq('$seqname') as id
Dr Bob Jansen
Turtle Lane Studios Pty Ltd
PO Box 26, Erskineville NSW 2043, Australia
Ph: +61-414 297 448
In line with the Australian anti-spam legislation, if you wish to receive no further email from me, please send me an email with the subject "No Spam"