0

transaction or deferred

the query below currently takes almost five minutes (browser) with just 30% of the final data expected. It's okay to wait this long , but I was wondering if anyone has an idea how to tweak its performance on the web app?

 

function define_td(my_training : Training,my_gen : Generation,add : boolean) do
    do as transaction
        let all_entries := (select entries);
        let xLabels := numbers(my_training.'included labels');
        let xElements := (select elements)[contains(xLabels, number('has label'))];
        let xSources := numbers(my_training.'by Source');
        let xUsers := numbers(my_training.'by User');
        let my_JSON := {};
        let corpus := all_entries[cnt(elements[contains(xLabels, number('has label'))]) > my_training.'min #elements' and
                cnt(elements.end_c > 0) > 0];
        if Filter = true then
            let corpus := (
                    corpus := corpus[contains(xUsers, number(creator)) and contains(xSources, number(Source))];
                    void
                );
            void
        end;
        for loop1 in corpus do
            my_JSON := {
                    entry_ID: number(loop1.ID),
                    entry: loop1.purged_entry,
                    entities: for loop2 in loop1.elements[contains(xLabels, number('has label')) and end_c != null and
                        (overlap_c = false or dismiss = true)] do
                        if add then
                            let newTD := (create 'Training Set');
                            newTD.(element := loop2);
                            newTD.(Generation := my_gen);
                            newTD.(JSON := 'JSON preview')
                        else
                            {
                                text: loop2.text_c,
                                start: loop2.start_c,
                                end: loop2.end_c,
                                label: loop2.'has label'.label,
                                ID_entity: number(loop2.ID),
                                ID_label: number(loop2.'has label'.Id)
                            }
                        end
                    end
                };
            my_JSON
        end
    end
end;
let my_T := this;
let newGen := (create Generation);
newGen.(Training := my_T);
define_td(this, newGen, true);
let my_JSON := define_td(this, newGen, false);
newGen.(JSON := formatJSON(my_JSON));
let J := {
        labels: unique(unique(my_T.Generation[Id = newGen].'Training Set'.element.'has label'.label))
    };
let my_labels := formatJSON(item(J, "labels"));
newGen.('labels included' := my_labels)

1 reply

null
    • Nick_Massie
    • 2 wk ago
    • Reported - view

    If you are on the public server move to a private server.  

Content aside

  • 2 wk agoLast active
  • 1Replies
  • 56Views
  • 2 Following